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 11 Answer
Reset to default -1You 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
版权声明:本文标题:plugins - WooCommerce Product Table - filter query on attributes 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742136894a2422410.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论