通过 WooCommerce API 获取与某个属性匹配的所有产品
我想找到一种方法来获取与属性品牌 = 226Ers 匹配的所有产品。例如。 我正在使用 automattic/woocommerce 包。 我尝试了一千种方法,但没有一个有效。 我查看了文档并检查了互联网,但我找不到执行此操作的方法。 这是一个例子:
$data = [
'attributes' => [
[
'id' => 3,// id of attribute Marca
'options' => '226Ers'
]
]
];
$this->productos = $woocommerce->get('products', $data);
I would like to find a way to get all the products that match an attribute brand = 226Ers. For example.
I am using the automattic/woocommerce package.
I have tried a thousand ways but none of them work.
I have looked at the documentation and checked the internet but I can't find the way to do it.
Here is an example:
$data = [
'attributes' => [
[
'id' => 3,// id of attribute Marca
'options' => '226Ers'
]
]
];
$this->productos = $woocommerce->get('products', $data);
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看来您应该传递属性和属性术语来检索按属性过滤的产品。来自( woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php 第 117 行 )
所以代码可能像
It seems like you should pass the attribute and the attribute term to retrieve the product filtered by attribute. From (
woocommerce/includes/rest-api/Controllers/Version3/class-wc-rest-products-controller.php Line 117
)So the code may like