Navigation
This is archived content. Visit our new forum.

Tagged: 

  • Author
    Posts
  • #1270834
    Sara H.
    Participant

    Hello!

    I was trying to hide woocommerce cart when is empty, I found this: https://community.theme.co/forums/topic/hide-woocommerce-cart-when-empty/

    I am having this fatal error now: Fatal error: Cannot redeclare x_woocommerce_navbar_menu_item() (previously declared in /home/rpparadise/www/www/rpparadise/wp-content/themes/x-child/functions.php:29) in /home/rpparadise/www/www/rpparadise/wp-content/themes/x-child/functions.php on line 112

    Can you help me?

    #1270835
    Sara H.
    Participant
    This reply has been marked as private.
    #1270838
    Sara H.
    Participant

    I guess its a conflict between:

    // Outputs a navigation item with the cart.

    and

    // Custom Cart menu when uberMenu is active

    Can you please advise? thanks!

    #1270950
    Friech
    Moderator

    Hi There,

    Thanks for writing in! Would you mind providing us with login credentials so we can take a closer look? To do this, you can make a post with the following info:

    – Link to your site
    – WordPress Admin username / password
    – FTP credentials

    Don’t forget to select Set as private reply. This ensures your information is only visible to our staff.

    Cheers!

    #1272177
    Sara H.
    Participant
    This reply has been marked as private.
    #1272208
    Thai
    Moderator

    Hi There,

    I’ve just fixed that issue, there are 2 functions with the same name in your functions.php file.

    Cheers!

    #1272325
    Sara H.
    Participant

    Hello! thanks a lot!

    but… sorry about this but I have my cart empty and I still can see the Woocommerce Cart in my NavBar.

    I have this code in my functions.php to hide the cart when is empty, but maybe I am wrong?

    // Outputs a navigation item with the cart.
    //
    
    function x_woocommerce_navbar_menu_item( $items, $args ) {
    
        if ( X_WOOCOMMERCE_IS_ACTIVE && x_get_option( 'x_woocommerce_header_menu_enable', '' ) == '1' ) {
          if ( $args->theme_location == 'primary' && WC()->cart->cart_contents_count > 0 ) {
            $items .= '<li class="menu-item current-menu-parent x-menu-item x-menu-item-woocommerce">'
                      . '<a href="' . x_get_cart_link() . '" class="x-btn-navbar-woocommerce">'
                        . x_woocommerce_navbar_cart()
                      . '</a>'
                    . '</li>';
          }
        }
    
        return $items;
    
      }
      add_filter( 'wp_nav_menu_items', 'x_woocommerce_navbar_menu_item', 9999, 2 );

    I got this code from here: https://community.theme.co/forums/topic/hide-woocommerce-cart-when-empty/

    #1272487
    Rad
    Moderator

    Hi there,

    Maybe it needs reloading? That can hide it, but not when added through Ajax. And if you will hide the card, how it will then be updated since it’s not there anymore. Or do you wish to remove them permanently?

    Thanks!

    #1273460
    Sara H.
    Participant

    The idea is to be hidden when is empty, not permanently is this possible?

    #1274012
    Friech
    Moderator

    Hey There,

    It could be possible with custom development, but this would be outside the scope of support we can offer. You may wish to consult a developer to assist you with this. X is quite extensible with child themes, so there are plenty of possibilities.

    Thanks for understanding.

  • <script> jQuery(function($){ $("#no-reply-1270834 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>