# Of Items In Cart Update Div?

HomeSupportImage Store# Of Items In Cart Update Div?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #78960
    jcharris
    Participant

    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

    #98457
    Xpark Media
    Keymaster

    @jcharris,

    Since 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
    });
Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.