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();
}
Hello There. I discovered your weblog the usage
of msn. This is a really smartly written article.
I will be sure to bookmark it and come back to learn extra of your helpful information. Thank you for the post.
I will definitely return.
My web-site … nordvpn coupons inspiresensation
Hi there! This is kind of off topic but I need some guidance from an established
blog. Is it very difficult to set up your own blog? I’m not very techincal but I can figure
things out pretty quick. I’m thinking about creating
my own but I’m not sure where to start. Do you have any ideas or suggestions?
With thanks
my web blog: nordvpn coupons inspiresensation