admin管理员组

文章数量:1323335

I am using the Barn2 Product Table plugin with WooCommerce. I would like to modify the main query so that only products with a certain attribute are displayed (depending on the logged in user)

I am using wc_product_table_query_args. To make it display products from a certain category is no problem and the following arguments work:

$query['tax_query'][] = array(
        'taxonomy' => 'product_cat',
        'field'    => 'slug',
        'terms' => array( 'sweatshirts' ),
        'operator' => 'IN',
);

However, I would like to change this so it works with an attribute instead of category e.g. where attribute name = Color, and attribute value = Red.

Any help is much appreciated, thanks.

I am using the Barn2 Product Table plugin with WooCommerce. I would like to modify the main query so that only products with a certain attribute are displayed (depending on the logged in user)

I am using wc_product_table_query_args. To make it display products from a certain category is no problem and the following arguments work:

$query['tax_query'][] = array(
        'taxonomy' => 'product_cat',
        'field'    => 'slug',
        'terms' => array( 'sweatshirts' ),
        'operator' => 'IN',
);

However, I would like to change this so it works with an attribute instead of category e.g. where attribute name = Color, and attribute value = Red.

Any help is much appreciated, thanks.

Share Improve this question asked Dec 21, 2019 at 16:21 mateo76mateo76 1
Add a comment  | 

1 Answer 1

Reset to default -1

You can do it with WOOT: https://products-tables/shortcode/woot/ - create 2 tables in admin panel and set predefinitions in their settings https://c2n.me/48YmMqO.png

Then create in file functions.php your own shortcode, where depending of the user logged-in or not, show one of the [woot] tables

本文标签: pluginsWooCommerce Product Tablefilter query on attributes