Due to terrible management I'm currently building an ecommerce from scratch. I got to the point where I need to do some lightweight stock management, and I figured that after the user sets their intention to buy something (proceed to check-out from cart), I should diminish the stock amount and create an order in the DB with pending status. However, I want to check if, after one day of this order being created, the status is still pending. If it is, then I should return the stock.
This would be easy if PHP had a function like JavaScript's setTimeout()
, but I'm finding it difficult to find similar functionality. I thought about creating a cron job, but I don't know how I could make it so that the executed script got all the necessary parameters to perform the status check (most importantly, the order ID).
Are there any other options?