我正在尝试使用woocommerce rest API here is the value that i want from woocommerce rest api获得自定义添加的属性以及变量产品的条款。但是我没有找到任何woocommerce rest api文档来获取可变产品的自定义属性和属性项。在此先感谢
这可以通过$ product-> get_attributes();
您可以尝试以下操作
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() );