Jump to content

Cart table is growing with unknown reason


ivanoman

Recommended Posts

Hi all, 
I'm using PS 9.1 and I noticed that the cart table is growing without having a real visitors choosing the product. 
Is there any way to avoid this? 
In the mean time I wrote a script that remove the table if not connected to anything. 

 

Quote

DELETE c, cp
FROM xxxx_cart c
LEFT JOIN xxx_orders o ON o.id_cart = c.id_cart
LEFT JOIN xxx_cart_product cp ON cp.id_cart = c.id_cart
WHERE o.id_cart IS NULL
  AND c.date_add < NOW() - INTERVAL 30 DAY;

What do you think ? 
 

Merry Chrustmas !! 
IM

Link to comment
Share on other sites

Hi,

This is usually normal in PrestaShop: a cart can be created just by visiting the site (session cookie), even without adding products. Bots, link previews, monitoring tools, etc. can generate many carts.

What to do:

  • Don’t delete “orphan” carts immediately. Just clean old carts (30/60/90 days).
  • Check server logs / Cloudflare to see if bots are causing it, and block them if needed.

Your SQL cleanup is OK if you keep the “older than X days” condition and you also delete related cart_product rows.

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...