|
private function resolveItem(StorageListInterface $storageList, StorageListItemInterface $storageListItem): void |
|
{ |
|
foreach ($storageList->getItems() as $item) { |
|
if ($this->cartItemResolver->equals($item, $storageListItem)) { |
|
$this->cartItemQuantityModifier->modify( |
|
$item, |
|
$item->getQuantity() + $storageListItem->getQuantity(), |
|
); |
|
|
|
return; |
|
} |
|
} |
|
|
|
$this->eventDispatcher->dispatch( |
|
new GenericEvent($storageList, ['item' => $storageListItem]), |
|
CartEvents::PRE_ADD_ITEM, |
|
); |
|
|
|
$storageList->addItem($storageListItem); |
|
|
|
$this->eventDispatcher->dispatch( |
|
new GenericEvent($storageList, ['item' => $storageListItem]), |
|
CartEvents::POST_ADD_ITEM, |
|
); |
|
} |
We have events to intercept the addition/removal of items in cart, but there is no way of intercepting if an already existing item in cart has it's quantity changed.
For example, we want to conditionally verify that only x number of products can be added to the cart. An event like coreshop.cart.pre_item_quantity_modified would really be helpful.
CoreShop/src/CoreShop/Component/Order/Cart/CartModifier.php
Lines 68 to 92 in d1822b1
We have events to intercept the addition/removal of items in cart, but there is no way of intercepting if an already existing item in cart has it's quantity changed.
For example, we want to conditionally verify that only x number of products can be added to the cart. An event like
coreshop.cart.pre_item_quantity_modifiedwould really be helpful.