Replies: 2 comments
-
Use Form Constraints to do that:
|
Beta Was this translation helpful? Give feedback.
0 replies
-
@dpfaffenbauer thanks for the quick response. Your solution seems to be for the total number of products in a cart. if ($this->cartItemResolver->equals($item, $storageListItem)) {
$this->eventDispatcher->dispatch(
new GenericEvent($storageList, ['item' => $storageListItem, 'quantity' => $item->getQuantity() + $storageListItem->getQuantity()]),
CartEvents::PRE_ITEM_MODIFY,
);
$this->cartItemQuantityModifier->modify(
$item,
$item->getQuantity() + $storageListItem->getQuantity(),
);
return;
} Something like this maybe? |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
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_modified
would really be helpful.Beta Was this translation helpful? Give feedback.
All reactions