Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/wordpress/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wordpress 如何使用woocommerce rest api v3获取自定义添加的可变产品属性和属性术语_Wordpress_Woocommerce_Woocommerce Rest Api - Fatal编程技术网

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

Wordpress 如何使用woocommerce rest api v3获取自定义添加的可变产品属性和属性术语,wordpress,woocommerce,woocommerce-rest-api,Wordpress,Woocommerce,Woocommerce Rest Api,我正在尝试使用woocommerce rest API获取一个可变产品的自定义添加属性及其术语。但我找不到任何关于获取变量产品的自定义属性和属性项的woocommerce rest api文档。提前感谢您可以尝试以下方法 1.get\u post\u meta获取产品属性 $attr = get_post_meta( 123, '_product_attributes' ); // replace 123 with the actual product id print_r( $attr );

我正在尝试使用woocommerce rest API获取一个可变产品的自定义添加属性及其术语。但我找不到任何关于获取变量产品的自定义属性和属性项的woocommerce rest api文档。提前感谢

您可以尝试以下方法

1.
get\u post\u meta
获取产品属性

$attr = get_post_meta( 123, '_product_attributes' ); // replace 123 with the actual product id 
print_r( $attr );
2.或者您可以创建一个产品对象,然后使用
get\u attributes
方法

$p = new WC_Product( 123 ); // // replace 123 with the actual product id 
print_r( $p->get_attributes() );