Hide WooCommerce Cart When Empty

Recommendation

Learn why I switched to WPCodeBox for managing code snippets for myself and for my clients.

Instructions

Snippet Type: JavaScript

  1. Copy the snippet.
  2. Add the snippet using WPCodeBox.
  3. Follow any customization notes provided.
  4. Save the snippet.
  5. Enable the snippet.
  6. Test.

Snippet

				
					jQuery( document ).ready( function( $ ) {
  
    setInterval(function(){
        if ($(".widget_shopping_cart_content .woocommerce-mini-cart__empty-message").length ) {
            $( '#user-cart-menu' ).hide();
        } else {
            $( '#user-cart-menu' ).show();
        }
    }, 10);
});