The Foxy forums are on the move!

We're in the process of moving our forums over to a new system, and so these forums are now read-only.
If you have a question about your store in the meantime, please don't hesitate to reach out to us via email.

Update Cart Data

jaushmanjaushman Member
in Bugs & Feature Requests edited October 2010
I am working on a site for a unique client. The product they sell expires every night at midnight and is replaced by a new product. We've found that if a customer has an existing cart the product will carry over with the cart session after the product has expired from our site. We need to be able to check the cart for expired products and remove them.

I've been successful at looping through the FC.json.products array to find expired products based on their unique code but I haven't been able to find a way to delete or modify an item (set quantity to 0, perhaps?). Is there a way to do this that I'm just overlooking?

Thanks for any help.
  • brettbrett FoxyCart Team
    You can definitely set the quantity to 0, but you may also want to use SSO to pre-authenticate the cart contents prior to allowing the customer through to checkout, and give them an expiration token set to midnight of your timezone.

    So even though you're not doing Single Sign-On, you use the functionality to do a pre-checkout validation. You get the fcsid passed in to your endpoint, at which point you can make a JSON request (serverside), parse the JSON (easy in most modern programming languages), and then take appropriate action like redirecting the user to an cart?empty=true&redirect=expired_explanation.html&fcsid=asdfasdf, which both empties their cart as well as explains what happened.

    If you don't need that level of robustness, the straight javascript approach would likely be 99% of what you need. Let us know if you need help.
  • Thanks for the ideas Brett. We are using SSO but the user experience feels strange to me if I let them continue to build a cart with incorrect values. I had a look at Alistairs blog post ( which led me to believe that I may be able to use cart?cart=update as a method to push updates to the cart but I've failed to get it to work. Is "update" a valid cart parameter? If so, is there documentation that I'm overlooking.
  • lukeluke FoxyCart Team
    It's not super obvious in the documentation, but yes, you can remove items from the cart using update and a JSONP call. There's a bit of information here that might be helpful:
Sign In or Register to comment.