Jump to content

automatically remove a product from the cart a certain period of time after it was added to the cart prestashop 1.7


Enzo Savoi

Recommended Posts

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.

Link to comment
Share on other sites

1 minute ago, ndiaga said:

Hi,

I   don't   know  what   project  is   about  and  why   you  need  to  remove  products  from  the  cart   but  I  see   customer   who  finish  there orders  after 

more  than   days  .

 

The script should run in the background, and be able to be activated multiple time at once

If   this  feature  is   a must   have   you  can try   cron  jobs.

We already talked about it, but my boss want it that way, anyway, I already thought about cronjob for the multiple activations, I'll try to follow the lead.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...