|

Woocommerce product category customizations

Remove subcategory count.

1
2
3
add_filter( 'woocommerce_subcategory_count_html', function(){
    return '';
});

Change the number of loop shop columns.

1
2
3
4
5
6
7
8
9
add_filter( 'loop_shop_columns', function(){
    $cat_obj = get_queried_object();
    $cat_id = $cat_obj->term_id;
    if( get_woocommerce_term_meta( $cat_id, 'display_type', true )== 'subcategories' ){
        return 3;
    }else{
        return 4;
    }
});

Change the number of loop shop columns css. Just add a class on the body tag.

1
2
3
4
5
6
7
8
9
10
add_filter( 'body_class', function ( $classes ){
    $cat_obj = get_queried_object();
    $cat_id = $cat_obj->term_id;
    if( is_woocommerce() && ( get_woocommerce_term_meta( $cat_id, 'display_type', true )== 'subcategories' ) ){
        $classes[] = 'columns-3';
    }else{
        $classes[] = '';
    }
    return $classes;
});

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *