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.

Making a unique product unavailable for sale if someone has it in their cart

I'm sure this has been asked before, but I can't seem to figure out the right search terms to find previous discussions!

I am looking for a way to sell unique products, where there is only one of each thing. For that to work, there needs to be a way to make the item unavailable when someone has it in their shopping cart. Is this possible?
  • fc_adamfc_adam FoxyCart Team

    Good question. As FoxyCart doesn't control your products or add to cart - there are a couple pieces to this, but it is possible - and some stores in the past have done it.

    In essence, the approach relies on tracking products as they're added and removed from the cart using our javascript events, and also tracking order completions, setting locks on the product inventory on your side.

    - When a customer adds the product to their cart, you'd send off an AJAX request to an endpoint on your side which places a temporary lock on that product inventory. As part of the add to cart, you would also make use of the expires attribute to set how long that product is allowed to be in the cart for (see more information on that at

    - It sounds like there is just 1 of each product - so you won't need to worry about quantity changes, but that'd be the same process.

    - Also, if someone removes the product, you'd send off an AJAX request to clear that inventory lock.

    - If someone completes their order, using the datafeed you can clear the inventory for that product and remove the lock.

    - Finally, assuming you put the same expiry timeframe on the lock on your side as the expires attribute for the product - the temporary lock should clear at the same time as the product becomes invalid in the customers cart. If they try to check out after the product has expired, their checkout will be stopped and the product automatically removed. For safety, it'd probably make sense to make the inventory lock just slightly longer than the product expires. That way you can be sure it has expired in the cart before it becomes available again on the website.

    - On your side - when displaying the add to cart, you'd need to also check against the inventory locks to check if that particular product still has available stock.
Sign In or Register to comment.