0

Is it possible to reserve the item the user adds to their cart?

For example, if there is an inventory of 2 and one user adds 2 to their cart, show this product as out of stock unless this user removes the items from their cart.

0

It does not appear that this functionality exists without extending CartThrob.

According to the documentation (as a note for the inventory:reduce tag), CartThrob does check the inventory when a product is added to the cart and when attempting to finalize the order. However, it does not appear that the inventory is modified when a product is added to the cart.

You could create an extension yourself that hooks into the many different hooks provided by CartThrob and updates the product's inventory when a product is added/deleted.

There are a couple of things you'll need to consider though:

  • Carts persist until they expire. It's possible someone could wipe out all of your inventory by adding all the products to their cart and then not touching their cart again. Of course, you could have a really low cart expiration time set so this wouldn't wipe out other customer's ability to purchase the items for too long.
  • Upon checkout, you would need to make sure that your modifications do not cause the math performed upon your inventory to be performed again upon checkout (when the inventory would be updated because it was purchased).
  • You'd want to make sure you update the inventory in bulk instead of individual sql queries for each item added/deleted so there is not a drag on performance.

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.