Skip to main content

If WooCommerce has item in cart add class to body

By May 29, 2020August 3rd, 2020No Comments

Super useful for complex WooCommerce configurations!

add_filter( 'body_class', 'add_body_class_for_cart_items' );
function add_body_class_for_cart_items( $classes ) {
    if( ! WC()->cart->is_empty() )
        $classes[] = 'has_items';

    return $classes;

Contact us to learn more about Adopt the Web for your business

Author Jarod Thornton

More posts by Jarod Thornton