Versionen im Vergleich

Schlüssel

  • Diese Zeile wurde hinzugefügt.
  • Diese Zeile wurde entfernt.
  • Formatierung wurde geändert.

...

Codeblock
languagejs
themeRDark
titleBeispiel js quantity change
collapsetrue
// ...

async myChangeAction() {

	if (
        false === this.configurator.blocked &&
        this.configurator.payload.hasOwnProperty('cartSessionArticle') &&
        this.configurator.payload.cartSessionArticle.shopSessionArticleQuantity !== this.quantity
    ) {
        this.configurator.payload.cartSessionArticle.shopSessionArticleQuantity = this.quantity
        this.configurator.payload.actions.push('MyChangeAction')
    
        this.configurator.change()
    }
}

// ...


Codeblock
languagephp
themeRDark
titleBeispiel php quantity change
collapsetrue
// ...

public const ACTION_QUANTITY = 'MyChangeAction';
public const PAYLOAD_KEY = 'cartSessionArticle';

// $payload = Configurator\Lib\Event\OnExecuteChange $event->payload

public function process(array $payload, ?Http\Response\AdvancedResponseStack $response): void
{
    if (
        array_key_exists('actions', $payload) &&
        in_array(self::ACTION_QUANTITY, $payload['actions']) &&
        array_key_exists(self::PAYLOAD_KEY, $payload) &&
        array_key_exists('shopSessionArticleQuantity', $payload[self::PAYLOAD_KEY])
    ) {
        $entity = $this
            ->staticController(CartSessionArticle\Manager::class)
            ->getConfiguratorRequestEntity()
        ;
        if ($entity instanceof CartSessionArticle\Lib\Struct\CartSessionArticle) {
            $quantity = (int)$payload[self::PAYLOAD_KEY]['shopSessionArticleQuantity'];
            $this
                ->staticController(CartSessionArticle\Lib\Execute\Quantity::class)
                ->execute($entity->sessionArticle, $quantity)
            ;

            if ($response instanceof Http\Response\AdvancedResponseStack) {
                $element = new CartSessionArticle\Lib\Response\StackAction\ConfiguratorQuantityUpdate();
                $element->quantity = $quantity;

                $response->add($element);
            }
        }
    }
}

// ...


Modul / eigenes Script laden

...