问题描述
我已将product_attributes创建为:Color
遇到了color
/ Size
遇到了size
我尝试使用wc_get_product_terms,但这是color / size
而不是var_dup(color / size)
信息的属性值。
解决方法
您可以使用wc_attribute_label()
通过以下方式获得product_attributes标签名称:
$attribute_slug = 'color';
$attribute_taxonomy = 'pa_' . $attr_slug;
echo wc_attribute_label( $attribute_taxonomy );
和
$attribute_slug = 'size';
$attribute_taxonomy = 'pa_' . $attr_slug;
echo wc_attribute_label( $attribute_taxonomy );