How to not show shortcode contents if cart is empty?
You can check the carts content then show the cart if it has some items // Add a WooCommerce Cart Total shortcode [cart_total] add_filter(‘woocommerce_add_to_cart_fragments’, ‘woocommerce_header_add_to_cart_fragment’); function woocommerce_header_add_to_cart_fragment( $fragments ) { global $woocommerce; ob_start(); ?> <a class=”cart-contents” href=”https://wordpress.stackexchange.com/questions/274073/<?php echo $woocommerce->cart->get_cart_url(); ?>” title=”<?php _e(‘View your shopping cart’, ‘woothemes’); ?>”><i class=”fa fa-shopping-cart “></i> <?php echo $woocommerce->cart->cart_contents_count;?></a> <?php $fragments[‘a.cart-contents’] = … Read more