Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #523122

    Hi there. I know this is more of a WooCommerce question than an Enfold question but do you know how to insert a body class like “woocommerce-items-in-cart” if the count of items in the cart is greater than zero. I’ve been tinkering with this and just can’t seem to get it to work.

    If not, no worries. If I find a solution on my own, I’ll post it here.

    Thanks!

    #523131

    Never mind. I figured it out!

    add_filter(‘body_class’, ‘pwm_woocommerce_cart_status’);
    function pwm_woocommerce_cart_status( $classes ){
    global $woocommerce;

    if( $woocommerce->cart->cart_contents_count > 0 ):
    $classes[] = ‘woocommerce-items-in-cart’;
    endif;
    return $classes;
    }

Viewing 2 posts - 1 through 2 (of 2 total)
  • The topic ‘Add body class if there are items in the cart?’ is closed to new replies.