Display ACF Field in Woocommerce View Order Details Page
-
Hello, I’m trying to display a ACF field that’s editable on admin order screen backend and displays on the woocommerce view order details page.
The field will display on other posts on the both the backend & frontend. It also appears in the backend on the admin edit order page but not the frontend. I’ve tried display a text area field like this <?php the_field( ‘the_testing’ ); ?> in the content.php, post.php, homepage.php and page.php of my theme.
I also used
<?php
$testing = the_field(‘the_testing’);
echo $testing;?>Another code tried////////
<?php add_action(‘woocommerce_view_order’, ‘display_acf_fields’ );
function display_acf_fields() {
$fields = get_field_objects();
if( $fields ): ?>Another code tried////////
<?php foreach( $fields as $field ): ?>
<?php echo $field[‘label’]; ?>: <?php echo $field[‘value’]; ?>
<?php endforeach; ?><?php endif;
}Another code tried////////
add_action( ‘woocommerce_view_order’, ‘add_custom_acf_field’, 10, 1 );
function add_custom_acf_field( $order_id ) {
if ( $order = wc_get_order( $order_id ) ) {
if ( !empty( $order->get_meta( ‘the_testing’ ) ) ) {
printf( ‘testing’, $order->get_meta( ‘the_testing’ ) );
}
}Field Label: testing
Field Name: the_testing
Type: Text Area
Location: Post Type = OrderI’ve tried deactivating all unnecessary plugins and switched to the default theme. I cannot seem to figure out how to display the ACF field & value in the frontend on the view order page. https://my.pervasiveconcierge.com/my-account/view-order/123456
- The topic ‘Display ACF Field in Woocommerce View Order Details Page’ is closed to new replies.