Describe the bug
During testing, I got the store to a situation, where I couldn't delete product from cart. It happened only on my phone and I can't (for now) reproduce it on desktop.
Steps to reproduce the issue:
Possible fix
If we added two more conditions to the query, it should fix it.
in_cart = 1 AND quantity > 0
Another question is, why and how are these entries which are not in_cart and have zero quantity even created?
How it looked (ignore the variables I output to the error)

The code causing the error
Database status for given id_cart and id_product
Database status for given query
Additional information
PrestaShop version: 1.7.6.0
PHP version: 7.2
Hi @Hlavtox,
Thanks for your report.
We have recently fixed two issues in PS1.7.7.0 similar to this problem.
Thanks to check & feedback.
@khouloudbelguith
Hi, none of these PRs seem to be related.
I don't know how the 'corrupted' entries happen, but adding these two restrictions to the query in controllers/front/CartController.php fix the issue. Have a look on it.
CHANGE FROM:
``
/**
* This process delete a product from the cart.
*/
protected function processDeleteProductInCart()
{
$customization_product = Db::getInstance()->executeS(
'SELECT * FROM' . _DB_PREFIX_ . 'customization'
. ' WHEREid_cart= ' . (int) $this->context->cart->id
. ' ANDid_product= ' . (int) $this->id_product
. ' ANDid_customization` != ' . (int) $this->customization_id
);
CHANGE TO:
```
/**
* This process delete a product from the cart.
*/
protected function processDeleteProductInCart()
{
$customization_product = Db::getInstance()->executeS(
'SELECT * FROM `' . _DB_PREFIX_ . 'customization`'
. ' WHERE `id_cart` = ' . (int) $this->context->cart->id
. ' AND `id_product` = ' . (int) $this->id_product
. ' AND `id_customization` != ' . (int) $this->customization_id
. ' AND `in_cart` = 1'
. ' AND `quantity` > 0'
);
@Hlavtox,
Would you be willing to make a pull request on GitHub with your code suggestion?
https://github.com/PrestaShop/PrestaShop/tree/develop
In the meantime, I will try to reproduce the issue:
Thank you!
Hi @khouloudbelguith
Customization:
@khouloudbelguith PR with a fix #16574
@Hlavtox, I did not manage to reproduce the issue with PS1.7.6.1 & PS1.7.6.2build1 & ps_shoppingcart v2.0.3
https://drive.google.com/file/d/1CXBDQC057LEs9F7G_Ki--Zg-5vZCID-R/view
Ping @sarahdib, could you please try to reproduce the issue.
Thanks!
@khouloudbelguith @sarahdib
Ladies, try it with a product that has combination, maybe it has something to do with it.
I just played with around with adding and removing customization, removing product from cart, changing quantity and I got it to this situation, where the entries existed (refer to the screenshots of my database.
@Hlavtox, it is OK
https://drive.google.com/file/d/1KwdvClsDnXe2GSYMTng9vRSsvOTIRmDl/view
Thanks!
@khouloudbelguith Managed to reproduce the issue. See the video:
https://drive.google.com/file/d/19SuT5YMueCVa-mG3AI2Bj1_kjB1qyZt8/view?usp=sharing
Hello @Hlavtox @khouloudbelguith
@Hlavtox Thank you for this precious information.
@khouloudbelguith I manage to reproduce the issue in 1.7.5.2, 1.7.6.2 and develop.
Hi @sarahdib, thank you!
@Hlavtox, thanks for these clarifications.
I鈥檒l add this to the debug roadmap.
Thanks!
@khouloudbelguith @sarahdib You are welcome.
I made a PR ladies, link above. Check it out, get it accepted and we have this solved. Have a nice day! :)
Fixed in #16574
I am running into this problem with a recent site and see that there is a fix with version 1.7.7. Is this version of Presta available?
@birdiesroom You can apply the fix to your current Prestashop, just add these two lines and fixed! :)
