Reputation: 480
I am trying to work something out in Magento, but I'm not sure what the best way of doing things are.
I am selling fabric/material, which is expensive. I am therefore allowing customers to purchase 'samples' of these fabrics.
What I need to do is: * Each of these samples are free ($00.00), but.. * If the customer has 5 or more items (no more than 15 items) then I need to add a surcharge of $20 (to cover P&P etc)
So if a customer has added 8 samples to their cart, they need to be charged whatever they have in their cart currently, plus $20 for the samples.
Could I do this in an observer method?
Many thanks
Upvotes: 1
Views: 7076
Reputation: 3682
This can be done with an observer, yes. To find relevant events for you to use, use this in the command line:
grep -rin -B2 -A2 "Mage::dispatchEvent" app/* > events.txt
Now you can easily search the events.txt
file for cart. Personally I would make an effort to update the cart, and not just update the total during checkout. Don't want to surprise visitors with any extra charges. So here are a few that might help:
checkout_cart_update_items_after
checkout_cart_product_add_after
checkout_cart_add_product_complete
checkout_cart_update_item_complete
checkout_cart_save_before
checkout_cart_save_after
Upvotes: 6