• Resolved L D

    (@ldaniels137)


    I am using the Storefront theme, wondering if the handheld footer menu on mobile can only display once a customer has added a product to the cart?

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Support kellymetal a11n

    (@kellymetal)

    Hi there,

    By default, that Storefront footer menu also provides access to the My Account page and search (not just to access the Cart contents). However, it should be possible to hide it when the Cart is empty.

    First, you could add a class to the HTML body element to indicate whether the Cart is empty or not:

    
    add_filter('body_class','add_cart_status_class_to_body');
    function add_cart_status_class_to_body($classes) {
        global $woocommerce;
    
        if ( $woocommerce->cart->cart_contents_count > 0 ) {
            $classes[] = 'cart-not-empty';
        } else {
            $classes[] = 'cart-empty';
        }
        return $classes;
    }
    

    That code should be added to your child theme’s functions.php file or via a plugin that allows custom functions to be added, such as the Code Snippets plugin. Please don’t add custom code directly to your parent theme’s functions.php file as this will be wiped entirely when you update.

    After that, you can hide the Storefront mobile footer bar based on that status:

    
    body.cart-empty .storefront-handheld-footer-bar {
      display:none;
    }
    

    You can add that to the “Additional CSS” section of your Customizer (Appearance > Customize).

    I hope that helps!

    Thread Starter L D

    (@ldaniels137)

    This worked perfectly! Thank you!

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Handheld footer menu on mobile’ is closed to new replies.