Shopping cart is not clearing on the cart page

I've also encountered this issue and I've found out that in vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml ~line 27, Magento Team seems missed to put a dot for the 'action' classname. It's a small mistake that creates a big problem. Hopefully this will be fixed in 2.2.7

So from

action.clear

It should be

.action.clear

*Note: Please don't edit the file in

vendor/magento/module-checkout/view/frontend/templates/cart/form.phtml

directly.*


When a user clicks on Clear Shopping Cart button then you have to check below:

  • On click on this button the http://{Example.com}/checkout/cart/updatePost/ should hit.

  • This URL must hit via POST request.

    This post request must have form_key and update_cart_action, and update_cart_action value should be empty_cart

FORM DATA should like when to click on Clear Shopping Cart

form_key: 4VQpuhYHzS9dOY3P
cart[15][qty]: 1
cart[17][qty]: 1
update_cart_action: empty_cart

Where 15,17 are cart item id.

If those are available or exist then the exception is not happening. You check error, check the exception log or changes

$this->messageManager->addException($exception, __('We can\'t update the shopping cart.'));

to

$this->messageManager->addError($exception->getMessage()

Tags:

Cart

Magento2