cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.2.6 clear shopping cart not working

SOLVED

Magento 2.2.6 clear shopping cart not working

I have just finished a development website on the Latest Magento version 2.2.6 using the Infortis Ultimo theme, I have noticed however that the clear shopping cart button appears to have no effect on the carts contents. The shipping estimate data does appear to clear on the button press though and individual items can be cleared. Is anyone else seeing this behaviour or is it my theme/installation?

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Magento 2.2.6 clear shopping cart not working

Hi @devantech_chris

 

Assuming clear cart means you are talking about remove button on the cart ? on click we can remove the item correct ? - If Yes , then i have double checked on the Vanila (Native) version of magento 2.2.6 and yes it is working fine.

 

I am able to clear the cart by removing the products - so yes it might be the theme issue.

 

Kindly change your theme to default (Luma) theme and then check , it will works !

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

View solution in original post

12 REPLIES 12

Re: Magento 2.2.6 clear shopping cart not working

Hi @devantech_chris

 

Assuming clear cart means you are talking about remove button on the cart ? on click we can remove the item correct ? - If Yes , then i have double checked on the Vanila (Native) version of magento 2.2.6 and yes it is working fine.

 

I am able to clear the cart by removing the products - so yes it might be the theme issue.

 

Kindly change your theme to default (Luma) theme and then check , it will works !

 

Hope it helps !

if issue solved,Click Kudos & Accept as Solution

Re: Magento 2.2.6 clear shopping cart not working

Hello @devantech_chris,

 

Can you please check on console, Did you get any error? If yes then please share it

 

--
If my answer is useful, please Accept as Solution & give Kudos

Re: Magento 2.2.6 clear shopping cart not working

Hi @gelanivishal,

 

There is no errors that appear on Chromes console I have also checked the system log, but there doesn't seem anything related. Its strange because the button clears the shipping estimate data. 

Infortis who produce our theme say it hasn't been tested with 2.2.6 (which is fair enough as it's new) but I see that shopping cart continuity over a page multiple refreshes was addressed in 2.2.6, so it made me wonder if its a Magento issue.

Re: Magento 2.2.6 clear shopping cart not working

Hi @Manthan Dave,

 

Thanks for that, I tried to have a look at Luma but oddly they appear to have removed the clear shopping cart button. I am happy to accept it works on your theme though :-)

Re: Magento 2.2.6 clear shopping cart not working

Hi @devantech_chris

 

Happy to help and keep helping Smiley Happy

if issue solved,Click Kudos & Accept as Solution

Re: Magento 2.2.6 clear shopping cart not working

It appears that Ultimo is not the issue as I have tried the default and it still gives issue.

I have managed to pretty much nail down what is causing the issue, just not enough know how about fixing it.

 

In /vendor/magento/module-checkout/Controller/Cart/UpdatePost.php

Line 102 should be returning the string value of the calling button, but it doesn't seem to for me...

$updateAction = (string)$this->getRequest()->getParam('update_cart_action');
 
The update cart works as its a default in the switch on the $updateAction string.
 

Re: Magento 2.2.6 clear shopping cart not working

I also have this problem, and I'm also using Infortis Ultimo.

Re: Magento 2.2.6 clear shopping cart not working

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

 

<table id="shopping-cart-table"
               class="cart items data table"
               data-mage-init='{"shoppingCart":{"emptyCartButton": "action.clear",
               "updateCartActionContainer": "#update_cart_action_container"}}'>

Empty cart button is set to strange value "action.clear"

When we have in vendor/magento/module-checkout/view/frontend/web/js/shopping-cart.js

            $(this.options.emptyCartButton).on('click', $.proxy(function () {
                $(this.options.emptyCartButton).attr('name', 'update_cart_action_temp');
                $(this.options.updateCartActionContainer)
                    .attr('name', 'update_cart_action').attr('value', 'empty_cart');
            }, this));

So we need to change "action.clear" to ".action.clear"

As I see the button "Clear cart" button simple triggering onSubmit event in vendor/magento/module-checkout/view/frontend/web/js/action/update-shopping-cart.js and nothing more.

 

Re: Magento 2.2.6 clear shopping cart not working


@devantech_chris wrote:

It appears that Ultimo is not the issue as I have tried the default and it still gives issue.

I have managed to pretty much nail down what is causing the issue, just not enough know how about fixing it.

 

In /vendor/magento/module-checkout/Controller/Cart/UpdatePost.php

Line 102 should be returning the string value of the calling button, but it doesn't seem to for me...

$updateAction = (string)$this->getRequest()->getParam('update_cart_action');
 
The update cart works as its a default in the switch on the $updateAction string.
 

I've also encountered this issue and just like @dylfin, I've also 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