最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

wp query - How can I filter products by meta in Woocommerce REST API?

programmeradmin4浏览0评论

I want filter products by meta_data in woocommerce rest api. I tried this, but not working:

$data = array(
                'numberposts'   => -1,
                'post_type'     => 'product',
                'meta_query' => array(
                    'relation'      => 'AND',
                    array(
                        'key'       => 'package_type',
                        'value'     => $filters['ad_type'],
                        'compare'   => '='
                    ),
                    array(
                        'key'       => 'package_location',
                        'value'     => $filters['ad_location'],
                        'compare'   => '='
                    ),
                    array(
                        'key'       => 'package_price_range',
                        'value'     => $filters['ad_price_range'],
                        'compare'   => '='
                    )
                )
            );

$_results = $this->woocommerce->get('products', $data);

It seems the $data filter is not prevail, it will get back the all product without filter. So the questions is, how can i use meta filters in api request?

发布评论

评论列表(0)

  1. 暂无评论