I am currently adding products programatically to the cart, to create a ‘free sample’ aspect to my site.
Currently, all of these products are $0 and you can add a maximum of 15. Once you have 5 ‘free sample’ products in the cart, I need to add $20 to the subtotal.
I know I can get the grandtotal using:
Mage::getSingleton('checkout/cart')->getQuote()->getGrandTotal();
But how do I access the subtotal and also add $20 to it?
I’m guessing I’ll need to write an observer, as I’ll need to check when products are added/removed from the cart in order to either add the $20 or not.
Has anyone done this before or could point me in the right direction of how I could do this?
Many thanks
Thanks
I actually answered this question recently here is a basic idea of what needs to be done, let me know if you need more specific details:
Add an observer which looks for this event ‘sales_quote_add_item’:
The observer should have a method which does something like this: