Support

Account

Home Forums Front-end Issues How do i display custom fields using Function.php Reply To: How do i display custom fields using Function.php

  • I think what you need to do is find the hook where you want these things displayed, have a look here:

    https://businessbloomer.com/woocommerce-visual-hook-guide-single-product-page/

    I think the closest hook is woocommerce_before_add_to_cart_form.

    Try this in your functions.php file:

    add_action('woocommerce_before_add_to_cart_form', 'display_product_fields' );
    function display_product_fields() {
    	$fields = get_field_objects();
    	if( $fields ): ?>
    		<ul>
    			<?php foreach( $fields as $field ): ?>
    				<li><?php echo $field['label']; ?>: <?php echo $field['value']; ?></li>
    			<?php endforeach; ?>
    		</ul>
    	<?php endif;
    }?>