'Issue filtering woocommerce products in PHP
Morning! this should be an easy one, I'm trying to filter products by 'Region' but my args don't seem to have any effect on my woocommerce product list generated from this query? Please help much appreciated.
$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 ) {}}
Solution 1:[1]
May be you need to change R to r
'Region' => 'Mexico' change to 'region' => 'Mexico'
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MANOJ VASHIST |
