0
votes

I have a Wordpress installation with Woocommerce and I added a ACF field to the orders. It's called 'booking_reference'.

Inside my functions.php file, on checkout I update the 'booking_reference' custom field. It gets saved to the database. All is working as it should.

In my next function i'm trying to email this custom field to the customer. I use this code:

$order_id   = $order->get_id();
$reference_number_acf_order = get_field('booking_reference', $order_id );

When I echo $reference_number_acf_order, it's empty. The $order_id variable is correct. It contains the order correct order ID.

The rest of the email to the customer is correct, it contains data from the order. Only the ACF value is empty.

1
If possible, share the process code you are doing to get more information about the problemjiali

1 Answers

0
votes

Are u using WP_Query() or something like in your new function?

If so. try calling wp_reset_query(); first:

wp_reset_query();
$reference_number_acf_order = get_field('booking_reference', $order_id );