WOOF - WooCommerce Products Filter

Manipulating by CSS class in tag body while filtering

If it is necessary to add any special CSS class in tag <body>, it is possible with hook ‘body_class‘.

Example:

add_filter('body_class', function($classes, $class) {
    global $WOOF;
    if (is_object($WOOF)) {
        if ($WOOF->is_isset_in_request_data($WOOF->get_swoof_search_slug())) {
            if ($WOOF->is_isset_in_request_data('pwb-brand')) {
                if ($WOOF->is_isset_in_request_data('really_curr_tax') AND intval($WOOF->get_request_data()['really_curr_tax']) === 23) {
                    $classes[] = 'term-shoes tax-product_cat';
                }
            }
        }
    }

    return $classes;
}, 10, 2);

 

On the code above is scenario: when WOOF searching is going by ‘brand’ and current page is page of category with ID 23 – system add CSS classes ‘term-shoes tax-product_cat‘ to tag <body>.