I am using Expresso with ExpressionEngine. I was wondering if there is a way to know what product was just added to the cart on return after the product is successfully added to the cart? I could add the {entry_id} to the end of the return parameter but was hoping there was a cleaner way of doing this.

What I am looking to do is that after a product is added to the cart I want to display a modal window with some related accessories to the product that was just added to the cart.



Just did a quick test and it appears Exp:resso cart show the most recently added item last in the cart items list so you could use the {if item:count == item:total_results} variable to do stuff, you may be able to use that to trigger your modal window...

  {!-- output titles of __}   

  {!-- if the last item do something here --}
  {if item:count == item:total_results}

  • That would work with one exception. If I add a product on return I could use that code and display the related products, exactly what I wanted but if I come back to the same product after browsing some other pages I would then get the related products again since that would still be the last item added to the cart. Maybe I could add some other parameter on the url, like success or something to signify a success add to cart and just check the specific segment for the value, which I think is better than putting the entry_id on the url. – Trevor Orr Nov 16 '13 at 19:40

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.