如何使用woocommerce rest api v3获取自定义添加的可变产品属性和属性项

问题描述 投票:0回答:2

我正在尝试使用woocommerce rest API here is the value that i want from woocommerce rest api获得自定义添加的属性以及变量产品的条款。但是我没有找到任何woocommerce rest api文档来获取可变产品的自定义属性和属性项。在此先感谢

wordpress woocommerce woocommerce-rest-api
2个回答
0
投票

这可以通过$ product-> get_attributes();


0
投票

您可以尝试以下操作

1. get_post_meta获取产品属性

$attr = get_post_meta( 123, '_product_attributes' ); // replace 123 with the actual product id 
print_r( $attr );

2。或者您可以创建一个产品对象,然后使用get_attributes方法

$p = new WC_Product( 123 ); // // replace 123 with the actual product id 
print_r( $p->get_attributes() );
© www.soinside.com 2019 - 2024. All rights reserved.