猿问

在 WooCommerce 中通过其别名获取产品属性标签名称

我已将 Product_attributes 创建为:Colorhave slug colorSizehas slugsize

在产品中:如何color通过 slug 显示名称/标签。

我尝试 wc_get_product_terms 但它是属性值而color / size不是var_dup(color / size)信息。


温温酱
浏览 116回答 1
1回答

蝴蝶不菲

您可以通过其 slug 获取 Product_attributes 标签名称,wc_attribute_label()例如:$attr_slug       = 'color';$attr_taxonomy   = 'pa_' . $attr_slug; echo wc_attribute_label( $attr_taxonomy );和$attr_slug       = 'size';$attr_taxonomy   = 'pa_' . $attr_slug; echo wc_attribute_label( $attr_taxonomy );
随时随地看视频慕课网APP
我要回答