Woocommerce FIlter Product using color and Category?

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP



Woocommerce FIlter Product using color and Category?



I am trying to integrate the woocommerce rest APIs with my Applications. All the defaults operations like get all products, get products by category etc are working perfectly fine.



but how i apply color filter in my code.?



bellow is my code.


$data = array(
'category' => $category_ids,
'attribute' => 'Options',
'attribute_term' => 'Blue',
'per_page' => 100,
'page' => 1
);
$temp = ($woocommerce->get('products', $data));




2 Answers
2



You just have to append 'pa' before your attribute name.
so if your using 'color' attribute then it is going to be 'pa_color'.And pass attribute_term id instead of slug or name in 'attribute_term'.



After Correction


$data = array(
'category' => $category_ids,
'attribute' => 'pa_color',
'attribute_term' => '27',
'per_page' => 100,
'page' => 1
);
$temp = ($woocommerce->get('products', $data));





Its's Work thank you so much its save my time...
– Parag Yelonde
Aug 11 at 9:56



Have you tried the WooCommerce forums?



Try https://www.woobeginner.com/woocommerce-support-forum/
or https://wordpress.org/support/plugin/woocommerce






By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

Firebase Auth - with Email and Password - Check user already registered

Dynamically update html content plain JS

How to determine optimal route across keyboard