// ...
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);
}
}
}
}
// ... |