Please submit a private ticket if you need to share sensitive information, such as license details and admin credentials.

Okay
  Public Ticket #2674181
Has anyone written code that hides the Shopping Cart on the menu bar if empty?
Closed

Comments

  • Scott started the conversation

    Hi,

    Love this plugin!

    Has anyone written a snippet that hides the Shopping Cart on the menu bar if the cart is empty?

    We see this discussion where the plugin author says that the "Hide if Empty" toggle hides the bubble icon, not the Menu bar item.  You can't hide the Menu Bar item if the cart is empty.

    We're trying to hide the menubar item if the cart is empty.  Does anyone have suggestions for how to do that?  Thank you!

  •  767
    Janilyn replied

    Hi Scott,

    Thank you for contacting WPClever Support Forum. 

    We’ve received your ticket and assigned one of our developers to help you with that. 

    He’ll be looking into your question and responding with specific instructions as soon as possible. 

    Please stay patient as we're having very heavy workloads, it might take some time for our developers to reach back.

    Best regards.

    Janilyn T. - WPClever Support Agent

  •  153
    Henry replied

    Hi Scott,

    You can try this CSS code:

    add_action( 'wp_head', 'wpc_emtycart_menu_check' );
    function wpc_emtycart_menu_check() {
        if (WC()->cart->cart_contents_count < 1) { 
            ?>
            <style>.woofc-menu-item.menu-item-type-woofc{display: none!important;}</style>
            <?php
        }
    }

    Best regards,
    Henry N.

  • Scott replied

    Thank you, that works great!

    In a separate ticket I will ask how we can bust cache so that the number on top of the Shopping Cart is correct.  But that is a separate issue, I think.

  •  153
    Henry replied

    Thanks for your feedback. I'm glad that it was solved / you have been able to figure it out.

    I'll consider your case closed and close your ticket now. Feel free to submit a new one in case you encounter any issues at any time. 

    Have a nice day and best regards. 

    Best regards,
    Henry N.