How to get custom fields in woocomerce Development

 

If you are using ACF plugin for custom fields in woo-commerce , here is the code how to get custom fields in short description on on single page content of woo-commerce.

Here we  made a Field Label is ‘Dimensions’ and Field Name is ‘Dimensions’ type ‘text ‘ and formatting ‘No formatting ‘ and leave blank all fields.

Only to get value use following code:-

$value = get_field( "text_field" );


Example:-

get_field(‘Dimensions’);

If value is empty then field name not displayed by following code:- 

$value = get_field( "text_field" );
if( $value ) {
        echo $value;
             } 
else {
        echo 'empty';
       }

Example:-

<tr><?php $value = get_field( ‘Dimensions’ );if( $value ) {
echo ‘<td>Dimensions:</td>’;
echo ‘<td>’. $value . ‘</td>’;
} else {
} ?></tr>