Display a variation’s custom field only if it has value
-
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 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.