1

I'm trying to validate and correct quantities of certain products being added from the frontend. I've found the checkout_cart_save_before event that fires during all frontend cart modifications. This is good, but I'm trying to see if there's a better and more efficient way of doing this, as, when listening to this event, I'll have to iterate through all of the products each time the cart is updated. This event also fires twice during a single cart update.

I've thought about rewriting specific controller actions, but that can be too intrusive as some actions don't have a convenient events to listen to modify quote item quantities.

There's also a Javascript method for each of the pages.. I understand the answers may be kind of an opinion, but I'd still like to obtain some feedback on this.

  • what is the aim of this? are you trying to do something on product add or later on? – David Manners May 30 '14 at 7:23
  • The idea is to impose a qty limit on specific products. checkout_cart_save_before works, but it fires twice when you add a product to cart (so you have to iterate through quote items twice) and only once when you simply reload/refresh/update the cart page. There's an alternative method I found to be better, and that's to listen to two separate events (add-to-cart and cart update events) separately. – musicliftsme May 30 '14 at 14:31
  • not sure 100% when they are fired but have you looked at catalog_product_type_prepare_full_options and catalog_product_type_prepare_lite_options checkout magento.stackexchange.com/a/9606/158 – David Manners May 30 '14 at 14:37
2

If you want to specify a max quantity, you can set it on the product admin in the inventory tab. The name of the field is Maximum qty allowed in the shopping cart.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.