Looking over the docs, there does not appear to be a clear way to display a custom field on the customer's order details page. I have no problem getting my custom fields to display on the admin order details or the customer's email.
The only way I can see that it can be done is if by copying over the "woocommerce/order/order-details.php" in the theme's folder. This is undesirable as it requires me to have a lingering template file that may or may not need to be updated if woo developers change the original.
Is there a filter that can allow me to add the custom field to the customer's order details page without relying on a template?
Just to clarify, the page I am looking to add this is when the user completes the order (their receipt page).
Many thanks!
Resolved. I missed this function in the docs.... "woocommerce_order_details_after_order_table".
This function will add your custom fields to the order details page. In my case...
add_action( 'woocommerce_order_details_after_order_table', 'nolo_custom_field_display_cust_order_meta', 10, 1 );
function nolo_custom_field_display_cust_order_meta($order){
echo '<p><strong>'.__('Pickup Location').':</strong> ' . get_post_meta( $order->id, 'Pickup Location', true ). '</p>';
echo '<p><strong>'.__('Pickup Date').':</strong> ' . get_post_meta( $order->id, 'Pickup Date', true ). '</p>';
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With