WooCommerce Tutorial
-
Hello WooCommerce
First Issue:
I followed your tutorial:
I successfully added a custom field of ‘Delivery Time’ to the Checkout page.
But when I look at the order via WooCommerce > Orders > Edit Order
The field is empty?!? (See Screenshot)This is your (my) code:
/** * Update the order meta with field value */ add_action( 'woocommerce_checkout_update_order_meta', 'my_custom_checkout_field_update_order_meta' ); function my_custom_checkout_field_update_order_meta( $order_id ) { if ( ! empty( $_POST['delivery_time'] ) ) { update_post_meta( $order_id, 'Deliver Time', sanitize_text_field( $_POST['delivery_time'] ) ); } } /** * Display field value on the order edit page */ add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 ); function my_custom_checkout_field_display_admin_order_meta($order){ echo '<p><strong>'.__('Delivery Time').':</strong> ' . get_post_meta( $order->id, 'delivery_time', true ) . '</p>'; }
Second Issue:
Obviously the customer would expect to see their delivery time on the Order Received page, otherwise it might result in an unnecessary email/phonecall,
so what code do I need to make the field appear on the Order Received page please?e.g. https://example.com/checkout/order-received
This wasn’t covered in the official tutorial.
Thanks in advance.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
- The topic ‘WooCommerce Tutorial’ is closed to new replies.