Answer the question
In order to leave comments, you need to log in
How to display optional attribute value in wordpress woocomerce?
<?php
global $product;
$attributes = $product->get_attributes();
foreach ( $attributes as $attribute ){
$name = wc_attribute_label( $attribute['name'] );
if ($name != 'Region' && $name != 'Fraction' && $name != 'BoostRating' && $name != 'BoostType1') {
echo "<div class='attributerow radio_wrap'><div class='attributerowname _hidden'>" . $name . "</div>";
if ( $attribute['is_taxonomy'] ) {
$values = wc_get_product_terms( $product->id, $attribute['name'], array( 'fields' => 'names' ) );
echo apply_filters( 'woocommerce_attribute', wptexturize( implode( ', ', $values ) ), $attribute, $values );
} else {
$values = array_map( 'trim', explode( WC_DELIMITER, $attribute['value'] ) );
echo apply_filters( 'woocommerce_attribute', wptexturize( '<div class="radio_line"><p class="radio_block radio"><a href="javascript:void(0)"></a><input type="radio" name="radio"><span class="atname">
'.implode( '</p></div><div class="radio_line"><p class="radio_block radio"><a href="javascript:void(0)"></a><input type="radio" name="radio"><span class="atprice">11</span><span class="atname">', $values ) . '</span></p></div></div>' ), $attribute, $values );
}
}
}
?>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question