Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 67836

Display a variation’s custom field only if it has value

$
0
0

Replies: 0

I created a custom field called Diameter and I want to display it only if it has value

I have the following in woocommerce / single-product / add-to-craft / variation.php:

<?php if ( !(empty(get_post_meta( $variation->get_id(), '_diameter', true )) ) ) : ?>
        <div class="product-diameter">
            {{{ data.variation.diameter }}}
        </div>
<?php endif; ?>

I tried $variation->get_id() but that didn’t seem to work

How do I get the get field value of a variation?


Viewing all articles
Browse latest Browse all 67836

Trending Articles