• 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?

    • This topic was modified 7 years, 5 months ago by dan11.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Display a variation’s custom field only if it has value’ is closed to new replies.