Woocommerce – Save custom field so shows in Order details and emails to user
Question
Hi I want to add an input field onto the order page where I can add a Serial Number once a customer has ordered a product.
I would like this to go under the Order details.
I know you can add notes but want this to be obvious on the order page.
I have tried the following:
// run the action
do_action( 'woocommerce_admin_order_data_after_order_details', $wccm_before_checkout );
// define the woocommerce_admin_order_data_after_order_details callback
function action_woocommerce_admin_order_data_after_order_details( $wccm_before_checkout ) {
<p class="form-field _serial_number_field ">
<label for="_serial_number">Serial Number</label><input type="text" class="short" style="" name="_serial_number" id="_serial_number" value="" placeholder="Serial Number"> </p>
<?php };
// add the action
add_action( 'woocommerce_admin_order_data_after_order_details', 'action_woocommerce_admin_order_data_after_order_details', 10, 1 );
I’m missing the save part but can’t get my head around what I need to do – so that the value I enter is saved to the product meta?
Any help would be appreciated
0
custom-field, post-meta, woocommerce
3 years
2020-04-06T12:53:39-05:00
2020-04-06T12:53:39-05:00 0 Answers
110 views
0
Leave an answer