How to move order notes field in WooCommerce Checkout page
The code snippet below will move the Order Comments field under shipping form, place them under the billing form and Update the Order Notes label in WooCommerce Checkout Page. Copy the code below and paste it in functions.php add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );
add_filter( 'woocommerce_checkout_fields' , 'wehelpcode_custom_order_notes' );
function wehelpcode_custom_order_notes( $fields ) {
$fields['billing']['new_order_notes'] = array(
'type' => 'textarea',
'label' => 'Customer Order Notes',
'class' => array('form-row-wide'),
'clear' => true,
'priority' => 999,
);
return $fields;
}
add_action( 'woocommerce_checkout_update_order_meta', 'wehelpcode_custom_field_value_to_order_notes', 10, 2 );
function wehelpcode_custom_field_value_to_order_notes( $order_id, $data ) {
if ( ! is_object( $order_id ) ) {
$order = wc_get_order( $order_id );
}
$order->set_customer_note( isset( $data['new_order_notes'] ) ? $data['new_order_notes'] : '' );
wc_create_order_note( $order_id, $data['new_order_notes'], true, true );
$order->save();
}