I have been asked to add a small script tag to our site to allow a third party service to track our abandoned carts so they can do marketing and retargeting. I wasn't given much information on how or where to implement this code, and I'm not very good with php (normally I stick to design and basic maintenance of the site). For now I'm planning on putting it in the footer.phtml of my theme so it doesn't hinder load times, although I may need to add it to the add to cart button itself. I am unsure which would be better.
The script tags normally reads
with real values in the curly brackets. The values for the subtotal and items skus need to be dynamic obviously, and I'm having trouble getting the values. (Again, I'm terrible with php.)
so far i'm trying this for the code (which I am sure is way off but hey, you gotta start somewhere):
It's not returning any values for either the subtotal or the items. I know for the items, that my code is probably terrible, but I was expecting the subtotals to return correctly. What am I doing wrong that the subtotals are not returning?
So far everything i've been seeing says that to call for the subtotal in the cart you use one of these:
Mage::helper('checkout/cart')->getQuote()->getSubtotal() Mage::helper('checkout/session')->getQuote()->getSubtotal() Mage::getSingleton('checkout/cart')->getQuote()->getSubtotal() Mage::getSingleton('checkout/session')->getQuote()->getSubtotal()
but using those seem to create fatal errors. Splitting the code into chunks like in my current code method seems to mitigate that, but obviously something is wrong.
What do I need to do?
If I understood it the right, by modifying your code in footer.phtml the following way:
You should get the desired result:
P.S. If that is not what you are looking for, please describe in more detail which parameters you would like to get?
P.S.S. just as a side note: you can get the subtotal this way, however, it's impossible to get product id using this scheme
Thank you for the help! It seems to work as I need it to so far.