Showing minicart icon in header on the right pages
-
Hi,
I am looking for help with mini cart placement for my demo page, thanks in advance. I have an ecommerce nav menu and a main site nave menu. The mini shopping cart icon is showing on all of the site pages while I want it to only show on the ecommerce pages.
I tried this in functions.php:
// Hide WooCommerce Cart Icon When Empty add_action( 'wp_footer', function() { if ( WC()->cart->is_empty() ) { echo '<style type="text/css">a.cart-contents.shopping-bag.has-svg-icon{ display: none; }</style>'; } });
Together with redirect to cart option selected in woocommerce settings (basically to refresh the page and display the cart in header once it has a product in cart).
This works almost perfectly and hides the cart icon on the main site pages (as it is empty before visiting shop), however it doesn’t redirect to cart from the product page add-to-cart button (redirect only works with the add to cart option on product thumbnail). This means that user can add an item to cart and the mini-cart icon doesn’t reappear until they hit refresh. This makes the flow break down.
How do you recommend displaying the mini cart icon only on shop pages?
Bw,
BenThe page I need help with: [log in to see the link]
- The topic ‘Showing minicart icon in header on the right pages’ is closed to new replies.