Hide cart if empty in PRO header bottom bar?

Is it possible to hide the cart toggle if cart is empty?

Thanks.

Hey @ak47marx,

Regretfully, that is not a feature currently offered by the cart elements so it would need custom development to achieve that. You will have to use a cart plugin or have a developer build one for you.

Thanks.

What would be a way to go with that or how should I start? I’m thinking maybe if I have someone to write a function snippet that says if cart empty then display:none cart div in header bottom bar. Could that even work if I give cart toggle some special id or css class?

Hi there,

That would do, controlling the visibility through javascript. And the developer should able to figure it out (with ID/Class or without).

Thanks!

Could this work if someone sets the classes right? https://theme.co/apex/forums/topic/showhide-ajax-cart/

I put a demo here https://www.plasticsurgeryholiday.com/shop/

Hi there,

For your case, you will need to add the Javascript code below to Pro > Launch > Theme Options > JS:

(function( $ ) {
	$(function() {
		setInterval(function(){
			if ($('.woocommerce-mini-cart__empty-message').length) {
				$('.hm9.x-bar-container').hide();
			} else {
				$('.hm9.x-bar-container').show();
			}
		}, 500);
	});
})(jQuery);

As already mentioned by my colleague this is considered as a customization request and outside of our support scope. The code above may or may not work as performant as you may consider and we will not be able to maintain the code or give additional support.

Thank you for your understanding.

Thank you so much, I’m one step closer. It does work but shows empty cart for a moment after each pageload, before gets hidden. I’ll try to figure it out.

Thanks again.

Hi There,

Further customizations from here would be getting into custom development, which is outside the scope of support we can offer. If you need more in depth changes, you may wish to consult with a developer.

Thanks for understanding!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.