早上!这应该很容易,我正在尝试按“地区”过滤产品,但我的参数似乎对该查询生成的woocommerce产品列表没有任何影响?请多多帮助。
$args = array(
'type' => 'product',
'meta_query' => array(
'_stock_status' => 'instock',
'Region' => 'Mexico'
)
);
foreach ( wc_get_products( array( $args, 'limit' => -1 ) ) as $product ) {
foreach ( $product->get_attributes() as $attr_name => $attr ) {}}
可能您需要将R更改为r
'Region' => 'Mexico' change to 'region' => 'Mexico'