Bring Your Business to Life › Support › Image Store › # Of Items In Cart Update Div?
- AuthorPosts
- April 8, 2014 at 4:07 pm #78960jcharrisParticipant
Hi,
We want to add a ‘# Of Items In Cart’ <div> at the top of the site on every page. (Lots of cart programs have this—think Amazon.com)
I created an ajax function to grab the value of
$ImStore->cart[‘items’]
…which works fine, except when adding an item to the cart because there is no page refresh.
Is there a way to hook into the updated # of items in the cart immediately after you update the cart total when one hits the ‘Add To Cart’ button? on order-form.php?
Ideally, the sequence would be:
1. User hits Add To Cart
2. The # Of Items In Cart would update from a global PHP var (this is where I hook in)
3. -Then- the light green message would display (Items added to cart).Suggestions?
TIA,
—JC
April 27, 2014 at 12:26 am #98457Xpark MediaKeymasterSince all data updates are ajax driven the only way to do it is using javascript. if you refresh the page php will always return the right value.
In version 3.4.7+ you will be able to bind a event listener to the window that will indicate the image was added.
$(window).bind('img_added_to_cart', function(){ // do something here });
- AuthorPosts
- You must be logged in to reply to this topic.