Dispay Custom field data in Woo commerce order dashboard(all order)
-
I added custom field on check out page after order notes. Also displayed a custom field data on the admin side in order edit page(single order) after address. I also want to display custom field data on Order Dashboard as in column.
Here is my code for custom field code./** * Add the field to the checkout */ add_action( 'woocommerce_after_order_notes', 'my_custom_checkout_field' ); function my_custom_checkout_field( $checkout ) { echo '<div id="my_custom_checkout_field"><h2>' . __('Reference Order') . '</h2>'; woocommerce_form_field( 'my_field_name', array( 'type' => 'text', 'class' => array('my-field-class form-row-wide'), 'label' => __('Have a Reference Order Number Given By Friend'), 'placeholder' => __('Reference Order Number'), ), $checkout->get_value( 'my_field_name' )); echo '</div>'; } /** * 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['my_field_name'] ) ) { update_post_meta( $order_id, 'Reference Order', sanitize_text_field( $_POST['my_field_name'] ) ); } }
Plz help me ASAP. Thanks.
- The topic ‘Dispay Custom field data in Woo commerce order dashboard(all order)’ is closed to new replies.