V
V
Valery232020-06-19 17:31:49
WordPress
Valery23, 2020-06-19 17:31:49

How to change the function so that "Similar Products" would have simple products?

WordPress site with WooCommerce plugin. I wrote a code that displays only simple products on the store page (does not display variable, etc.). But I can't write a similar function for "Similar Products" inside products. Maybe someone will tell?

add_filter('woocommerce_product_query_tax_query', 'custom_product_query_tax_query', 30, 4 );
function custom_product_query_tax_query( $tax_query, $query ) {
    if( !is_shop()  ) return $tax_query;

    $tax_query[] = array(
        'taxonomy'  => 'product_type',
        'field'     => 'name',
        'terms'     => array('simple'),
    );

    return $tax_query;
}

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question