Closed. This question is off-topic. It is not currently accepting answers.admin管理员组文章数量:1287120
Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 3 years ago.
Improve this questionI'm trying to list all my product brands in a single page, currently i'm able to get only 100 brands per page by using wp-json/wc/v3/products/brands?per_page=100.
but if i set per_page=200, i'm getting status 400 with the following error
{"code":"rest_invalid_param","message":"Invalid parameter(s): per_page","data":{"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"}}}
is there any way i can set a maximum limit to 200 in the functions.php. I checked the documentation, i couldn't find anything that is useful.
Please note that i already set the maximum query limit for products like this in the functions.php
add_filter('rest_product_collection_params', 'maximum_api_filter');
function maximum_api_filter($query_params) {
$query_params['per_page']["maximum"]=300;
return $query_params;
}
is there a similar way to achieve this for brands also ?
Closed. This question is off-topic. It is not currently accepting answers.Your question should be specific to WordPress. Generic PHP/JS/SQL/HTML/CSS questions might be better asked at Stack Overflow or another appropriate Stack Exchange network site. Third-party plugins and themes are off-topic for this site; they are better asked about at their developers' support routes.
Closed 3 years ago.
Improve this questionI'm trying to list all my product brands in a single page, currently i'm able to get only 100 brands per page by using wp-json/wc/v3/products/brands?per_page=100.
but if i set per_page=200, i'm getting status 400 with the following error
{"code":"rest_invalid_param","message":"Invalid parameter(s): per_page","data":{"status":400,"params":{"per_page":"per_page must be between 1 (inclusive) and 100 (inclusive)"}}}
is there any way i can set a maximum limit to 200 in the functions.php. I checked the documentation, i couldn't find anything that is useful.
Please note that i already set the maximum query limit for products like this in the functions.php
add_filter('rest_product_collection_params', 'maximum_api_filter');
function maximum_api_filter($query_params) {
$query_params['per_page']["maximum"]=300;
return $query_params;
}
is there a similar way to achieve this for brands also ?
Share Improve this question asked Feb 17, 2021 at 7:14 Asif RahmanAsif Rahman 11 bronze badge1 Answer
Reset to default 1There are no brand fields in WooCommerce core by default. This answer comes from a post 2 years ago, given by an engineer from Automattic. I double-checked the validity of this answer again today.
Yes correct use vendor_id or another field which is valid. Let me share mine which was worked for me.
i place exactly same code in function.php file.
add_filter('rest_product_collection_params', 'maximum_api_filter'); function maximum_api_filter($query_params) { $query_params['per_page']["maximum"]=300; return $query_params; }
but my filter was like-
wp-json/wc/v3/products?status=publish&vendor_id=13&lang=en&per_page=300&
本文标签: Woocommerce REST APIadd filter to set maximum query per page for product brands
版权声明:本文标题:Woocommerce REST API - add filter to set maximum query per page for product brands 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741306185a2371382.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论