Okay
  Public Ticket #2498616
Hide cart icon if empty
Closed

Comments

  •  1
    ToM started the conversation

    Hello,

    I would like to know if there is a way to hide the cart icon from the header only when the cart is empty.


    Thanks in advance for your help.


  •  2,965
    Andrew replied

    Hi there,

    We currently do not have a setting for this. It can also not be achieved using CSS alone.

    You will need to write custom functions to achieve this.

    Regards.

  •  1
    ToM replied

    Hi Andrew,

    Thank you for your reply.

    This feature is available on the demo http://themenectar.com/demo/salient-business/shop/

    The Cart icon appears only when you add a product.  

    I would like to have this function from this demo, just don't know where to find it.

    Thanks 

  •  2,965
    Andrew replied

    Hi there,

    Use the left header layout in Salient > Layout related.

    9744371994.png


    Thanks.

  •  1
    ToM replied

    Hi Andrew,

    Not 100% helpful, anyway thank you for your time  :)
    (This setting is also available with the Original Theme Skin)

    It will be nice to add the feature  "Hide WooCommerce Cart in Nav if empty" for the next updates.
    It can be great especially with the minimalist headers and menus from your last demos.

    If somebody needs, as you suggest, I've added a custom function and disable "AJAX on add to cart buttons on archives" (from WooCommerce Products Settings). If not, the cart will not appear the first time you add a product.

    Not the best, but this quick fix works

    add_action( 'wp_footer', 'remove_empty_cart_icon');
    function remove_empty_cart_icon () {
        if ( WC()->cart->get_cart_contents_count() == 0 ) {
            echo '<style type="text/css"> .nectar-woo-cart, #mobile-cart-link {display: none !important;}</style>';
        }
    };
    

    But yeah, you have in hands a better way to do it from your demo http://themenectar.com/demo/salient-business/shop/ and  http://themenectar.com/demo/salient/ :)