Only show shopping cart for mobile devices when at least one product is added to cart


#1

I would like to only show the “Shopping Cart for Mobile Devices” when a user has something in the cart. It’s kind of annoying to have it on the site at all times showing “0” products in cart, which is the current default.

Is it possible to set a parameter to only show the cart icon once at least 1 product is added to the cart?

I think that would be a pretty nice feature and would help clean up the mobile experience.

Thanks!


#2

we found it annoying also in the desktop version :wink:

this works as a fix:
go to Design, Themes Editor
edit views/header/master/checkout.php

insert the following line at line 16 (in a line before the closing tag ?> )
if (WC()->cart->cart_contents_count > 0) {

and on the bottom of the script, close the if bracket:
<?php
}
?>
(this will check if there are more than 0 elements in the cart)

and on the end insert
<?php
}

but would be nice to have two switches for “show only when not empty”


#3

ps: the fix I wrote above works only for the desktop version.
mobile version is located in jupiter⁄framework⁄plugin-integrations⁄woocommerce⁄init.php
(open if bracket in line 240 before ?>, close it in line 250 after <?php
and support told me it’s not possible to edit that file in a child theme