Hello everyone, I would like to try and found a way to automatically remove a product from the cart after a period of time passed. Let me give you an example
at 10.00 AM the client adds "Product A" to his cart.
at 11.00 AM the client adds "Product B" to his cart.
Let's imagine he comes back at 13.00 PM and we set our time limit to 3 hours (or 10 800 seconds)
then product A will be automatically removed from his cart.
I do not wish to just empty the cart completely, just the products who've been in it for some time automatically.
So theoretically here's how I think it could work.
Step 1) when product is added thx to add_to_cart, after it's added the product id and the date and time in which it was added is noted somewhere, as well as a $limit_time : (which will basically be the date and time + the temporal limit we want) example : $actual_time = date('d-m-y h:i:s'); and $limit_time = date("Y-m-d H:i:s", strtotime('+3 hours')). )
Step 2) find a way to verify when actual_time is equal to limit_time, basically 3 hours later.
Step 3) when actual_time is equal to limit_time recuperate the id product and remove it from the cart
The script should run in the background, and be able to be activated multiple time at once, each for every item in the cart, and if the product is removed manually from the cart the specific script related to that product.
If anyone has any idea of how to set all that up, if someone already did something akin to that, or if you have another way to put this out do not hesitate to tell me, I really need to find a way to do that.