Support › General › How to output Custom Fields with functions.phpResolved
I am new to Metabox.io and I am looking for a way to output custom fields to a Single product page (WooCommerce) below the short description text.
I know how to output the custom field I created with Metabox.io directly in the template pages using:
<?php $value = rwmb_meta( 'my_custom_field' ) ?>
<p>Here comes the custom field: <?= $value ?></p>
But is there a way to add a function in functions.php to output the custom field with the hook "woocommerce_before_add_to_cart_quantity"?
By the way… I am using a Block Theme (Gutenberg).
Thanks for help,
The helper function can help you to output the field value anywhere on the site, the main goal is to pass the field ID and post ID to the function, like this
<?php $value = rwmb_meta( 'my_custom_field', '', $post_id ) ?>
You can contact WooCommerce support or your theme support to ask for getting the post ID when using the hook.
Okay, thanks. I will have a look at it.