Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #692770

    Hi,

    I’ve selected in the Theme Options Header Shopping Cart Icon: Always Display attached to the main menu

    But, I’d like to remove the icon only when the cart is empty… of course it isn’t possible using CSS

    Could you help me to find out a solution?

    Many thanks in advance, team!

    #692772

    Hey Dario!

    Please try adding following code to Quick CSS in Enfold theme options under General Styling tab

    .cart_dropdown.av-display-cart-on-load {
        display: block !important;
    }
    .cart_dropdown {
        display: none !important;
    }

    Regards,
    Yigit

    #692811

    Thanks for your reply, Yigit!

    The issue could be if your cart is NOT empty and the page is reloaded…
    So, you won’t be able to checkout…

    Could you provide me other solution, maybe using function?

    Many thanks!

    #693049

    Hi Dario,

    Have you tried the code Yigit provided? The css only hides the cart when it is empty but there is a different class when the cart has something in it which displays the cart again.

    Let us know if we are still misunderstanding.

    Best regards,
    Jordan

    #693073

    Hi Jordan,

    my goal is to show the cart ONLY when a product is added.

    – 1 or more products: cart is visible
    – no products: cart is NO visible

    That is why I thought that it was easily to program using function.php

    Many thanks in advance for your reply!

    • This reply was modified 8 years, 1 month ago by Dario.
    #694396

    Hi,

    Please remove the css modification then add this in the functions.php file:

    function add_custom_script(){
    ?>
    <script type="text/javascript">
    (function($){
    	function a() {
            var empty = $('.cart_list .empty').length;
    	    if(empty > 0) $('.cart_dropdown').addClass('hide_cart');
    	}
    
    	setTimeout(function() {
    		a();
    	}, 500);
    
    	function b() {
    	    $('#top .avia_cart_buttons .button').bind('click', function() {
                var empty = $('.cart_list .empty').length;
    		    if(!empty) return;
    
    			$('.cart_dropdown').removeClass('hide_cart');
    		    $('.cart_dropdown').addClass('show_cart');
    	    });
    	}
    
    	b();
    })(jQuery);
    </script>
    <?php
    }
    add_action('wp_footer', 'add_custom_script');
    

    And the following css code in the Quick CSS field:

    @media only screen and (min-width: 767px) {
        .responsive #top .cart_dropdown {
            opacity: 1;
        }
    
        .responsive #top .cart_dropdown.hide_cart {
            opacity: 0;
        }
    
        .responsive #top .cart_dropdown.show_cart {
            opacity: 1;
        }
    }

    Best regards,
    Ismaelo

Viewing 6 posts - 1 through 6 (of 6 total)
  • You must be logged in to reply to this topic.