【发布时间】:2016-07-13 16:59:12
【问题描述】:
我需要有关 WordPress Woocommerce 的帮助。
如何回显产品自定义属性的值?
问题:属性值全部打印在一行中。 我只需要在每一行打印出 1 个值
这是我的代码。
global $product;
if ( ! $product->is_purchasable() ) {
return;
}
$custom_attr_values = array_shift( wc_get_product_terms( $product->id, 'first-attribute-name', array( 'fields' => 'names' ) ) );
?>
<div class="selection">
<font color="white">First Attribute Name</font>
<select>
<option value=""><?php
$subheadingvalues = get_the_terms( $product->id, 'pa_first-attribute-name');
foreach ( $subheadingvalues as $subheadingvalue ) {
echo $subheadingvalue->name;
}
?></option>
<option value=""><?php
$subheadingvalues = get_the_terms( $product->id, 'pa_first-attribute-name');
foreach ( $subheadingvalues as $subheadingvalue ) {
echo $subheadingvalue->name;
}
?></option>
<option value=""><?php
$subheadingvalues = get_the_terms( $product->id, 'pa_first-attribute-name');
foreach ( $subheadingvalues as $subheadingvalue ) {
echo $subheadingvalue->name;
}
?></option>
<option value=""><?php
$subheadingvalues = get_the_terms( $product->id, 'pa_first-attribute-name');
foreach ( $subheadingvalues as $subheadingvalue ) {
echo $subheadingvalue->name;
}
?></option>
</select>
【问题讨论】:
标签: php woocommerce attributes echo