Reputation: 5483
I want to display a specific product attribute on my product page in WooCommerce. But I want to show not only the name but some extra information like a description and an image.
At the moment I'm using wc_get_product_terms
for that:
<?php
global $product;
$values = wc_get_product_terms( $product->id, 'pa_attribute', array( 'fields' => 'all' ) ); if( $values ) : ?>
<div class="woocommerce-product-details>
<div class="content">
<ul class="list-unstyled">
<?php foreach ( $values as $term ) : ?>
<li class="">
<?php $icon = get_field('pa_attribute_icon', 'pa_attribute_'.$term->term_id); if( !empty($icon) ): ?>
<div class="highlight-img"><img src="<?php echo $icon['url']; ?>" alt="<?php echo $icon['alt']; ?>" /></div>
<?php endif; ?>
<div class="highlight-label"><?php echo $term->name; ?></div>
</li>
<?php endforeach; ?>
</ul>
</div>
</div>
<?php endif; ?>
I have read, that wc_get_product_terms
is deprecated. Is there a better/newer solution to display the attributes with the additional informations?
Upvotes: 1
Views: 555
Reputation: 36
wc_get_product_terms
is not deprecated. woocommerce_get_product_terms
it is.
Upvotes: 2