A client recently requested me to change how the “add to cart” feature works. He explained that their customers are required to buy products in a full case, which the quantity can be 6, 12, etc, but their inventory quantity is in a single unit. So I couldn’t just raise the price to match the price of a case. After digging around a bit, I found that there is an observer I can hook into, to change the add to cart quantity.
First, You will need a new product attribute to store the case size. I called it “case_size”
And then you will create an extension to observe “sales_quote_item_qty_set_after” event. I assume you have experience on creating an event observer! If you don’t… Here is a tutorial
The above code manipulates the input quantity by multiplying it to the case size. However, there are a few cases that you don’t want to apply the multiplication, e.g the item is being added to cart by the reorder function.