2

I am using Magento 2.4.3 EE

Is there any way we can remove all products from the cart using the cart id?

I have checked on using "removeItem" & "deleteItem" but it needs to loop the cart items which is not suitable when the cart has more than 400+ products.

Any thoughts on this?

3

2 Answers 2

1

Magento\Quote\Model\Quote::removeAllItems()

0

By cart id I assume you mean quote_id? you can just use some SQL if this is a one off fix :

delete FROM `quote_item` WHERE quote_id = X
3
  • This is not the recommended method. Also i meant initiating cart object using quote id & delete all the cart items exist in it.
    – devhs
    Commented Sep 30, 2021 at 10:14
  • Understood, but im assuming you're asking because of this? magento.stackexchange.com/questions/347432/… if the recommended method was perfectly written code then the Remove all button should be able to handle this task. Since it can't best to look around. Commented Sep 30, 2021 at 10:23
  • not sure about it.
    – devhs
    Commented Sep 30, 2021 at 10:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.