Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theUnforgiven's avatar

Shopping Cart Session Handling [HELP]

Hi all,

I'm wanting to add a session to my shopping cart that will set the stock of the selected item(s) to zero for say 15 mins, until the stripe payment is completed. If the stripe payment isn't completed within the 15 minutes, the stock then becomes 1 (one) again and available for sale.

I'm wondering how to best approach this and help me get my head around it.

NOTE: I'm using 5.3 and the Gloudemans\Shoppingcart package.

Any help & advise greatly appreciated.

0 likes
8 replies
chriss39's avatar

I have never used Gloudemans shoppingcart but I would potentially design it differently. If you are looking to lock the item kind of like buying a concert ticket and you have x minutes to complete your purchase I would have a table that holds that information and takes the item out of stock. Then if they cancel and/or have a cron job or event that would check that table for expired ones and add it back to the inventory.

chriss39's avatar

create a table for locked inventory with product_id, exp time, anything else relevant. When user adds a product to the cart remove one from quantity available and add record to new table. Once they complete purchase remove that record from new table. Also have a job running that will check for expired rows in that new table and if so remove the record and add back the inventory to product/inventory table.

Should be fairly basic to do just take some time and testing.

1 like

Please or to participate in this conversation.