PrestaShop

Random product added to cart along with selected product in PrestaShop [solved]

Using PrestaShop 1.6.1.18, this was an older shop that had been offline for a couple of years. It had been upgraded in steps from PrestaShop 1.4 via 1.5 to 1.6. While testing it before relaunch of the shop a problem was discovered. Sometimes when adding a product to the shopping cart, another random product was added. When testing the shop in incognito/private mode this happened more frequent.

It turned out to be a discrepancy between cart ID:s in the two tables ps_cart and ps_cart_product.

Solution:

  1. Use phpMyAdmin or similar to open your PrestaShop database.
  2. Go to the table ps_cart_product, make sure it is ordered by the id_cart column and go to the last page.
  3. Make a note of the highest id_cart value.
  4. Go to the table ps_cart, make sure it is ordered by the id_cart column and go to the last page.
  5. Compare this table’s highest id_cart value with the one you found in ps_cart_product. It will probably be a lower number and this is what is causing the problem. When a visitor puts something in a cart, a new row is created in ps_cart with id_cart value auto incremented but there is already a row in ps_cart_product with this id_cart value from a previous visitor.
  6. Add a new row to ps_cart and in the id_cart field enter the number of the highest value you found in ps_cart_product. Then save the row.
  7. You will probably see some error message about invalid or missing fields but that will be ok as long as the row is saved.

 

0 replies

Leave a Reply

Want to join the discussion?
Feel free to contribute!

Leave a Reply

Your email address will not be published. Required fields are marked *

15 − three =