Hello,
I created a custom fields group to be displayed on Order pages. I’d like these custom fields to be displayed on the checkout page (WooC Pay page or pay-order) so that the customer can view the details and do her/his checkout.
https://drive.google.com/file/d/1UIsAYH3rODa-hPgULClMzAgZogeD9PDv/view?usp=sharing
Added a code block on form-pay.php to display my tour_start_date, as an example, however, it failed:
$tour_star_date = get_field( ‘tour_start_date’, $item->get_product_id() );
echo ‘<p>’ . $tour_star_date . ‘</p>’;
How can I display them on these pages, could you please help or guide me?
Thank you.
you need to use the order ID here, not the product ID
$tour_star_date = get_field( ‘tour_start_date’, $item->get_product_id() );
Hi John,
Thank you so much for your reply. But unfortunately it doesn’t work 🙁
https://drive.google.com/file/d/1YJrxKaEKjtQ0pJOxnG_0n33H6TgVKczg/view?usp=sharing
Did I miss something?
I honestly don’t know the answer. This is a WC thing. You are displaying the order page, the fields are saved against the “order” post. You need to supply the ID of that order post. So what you need to do is look into the WC documentation on how to get the ID of the order being shown.
Hi John!
Thank you so much for your feedback.
This worked as expected:
$acf_field_name = get_field('acf_field_name', $item->get_order_id());