Woocommerce REST API – filtering wp-json/wc/v3/products
-
This is gonna be a little more technical than a regular support requests, but I direly need help with this so here goes:
Is there a way – through the functions.php or other – to add custom filters to Woocommerce’s wp-json/wc/v3/products endpoint?
First off, i’m aware you can add parameters/endpoints to this URL, however this exact path is accessed by an external tool we use so I have no way to change the URL itself.I would like to tell WooCommerce that if this exact URL is accessed, some products should not be sent.
Adding additional filters like /categories to the URL sadly is not an option, it needs to be wp-json/wc/v3/products exactly.Here’s what i tried to exclude the product with ID 10522which doesn’t quite seem to work:
function maximum_api_filter($query_params) { $query_params['exclude'][10522]; return $query_params; } add_filter('rest_product_collection_params', 'maximum_api_filter');
- The topic ‘Woocommerce REST API – filtering wp-json/wc/v3/products’ is closed to new replies.