WooCommerce: Move Order Notes @ Checkout

We already saw how to hide Order Notes on the WooCommerce checkout page. This time around, however, our goal is to “move” them – and specifically remove them from their default position (under the shipping form) and add them back under the billing form.

As you can imagine, this is a combo snippet: (1) we remove them (and we’ll use the snippet as per the link above) and (2) we create a new billing field. Finally, (3) we also need to “save” this new field value into the original order notes custom field meta.

If this is difficult to understand don’t worry – just copy/paste the snippet into your functions.php and see magic happen. Enjoy!

Moving order notes from below shipping to the billing form @ WooCommerce Checkout

PHP Snippet: Move Order Notes @ WooCommerce Checkout

/**
 * @snippet       Move Order Notes @ WooCommerce Checkout
 * @how-to        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    WooCommerce 3.9
 * @community     https://businessbloomer.com/club/
 */

// 1. Hide default notes

add_filter( 'woocommerce_enable_order_notes_field', '__return_false' );

// 2. Create new billing field

add_filter( 'woocommerce_checkout_fields' , 'bbloomer_custom_order_notes' );

function bbloomer_custom_order_notes( $fields ) {
	$fields['billing']['new_order_notes'] = array(
		'type' => 'textarea',
		'label' => 'New Order Notes',
		'class' => array('form-row-wide'),
		'clear' => true,
		'priority' => 999,
	);
	return $fields;
}

// 3. Save to existing order notes

add_action( 'woocommerce_checkout_update_order_meta', 'bbloomer_custom_field_value_to_order_notes', 10, 2 );

function bbloomer_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();
}


Where to add custom code?

You should place custom PHP in functions.php and custom CSS in style.css of your child theme: where to place WooCommerce customization?

This code still works, unless you report otherwise. To exclude conflicts, temporarily switch to the Storefront theme, disable all plugins except WooCommerce, and test the snippet again: WooCommerce troubleshooting 101

Related content

  • WooCommerce: Cart and Checkout on the Same Page
    This is your ultimate guide – complete with shortcodes, snippets and workarounds – to completely skip the Cart page and have both cart table and checkout form on the same (Checkout) page. But first… why’d you want to do this? Well, if you sell high ticket products (i.e. on average, you sell no more than […]
  • WooCommerce: Disable Payment Method If Product Category @ Cart
    Today we take a look at the WooCommerce Checkout and specifically at how to disable a payment gateway (e.g. PayPal) if a specific product category is in the Cart. There are two tasks to code in this case: (1) based on all the products in the Cart, calculate the list of product categories in the […]
  • WooCommerce: Add Privacy Policy Checkbox @ Checkout
    Here’s a snippet regarding the checkout page. If you’ve been affected by GDPR, you will know you now need users to give you Privacy Policy consent. Or, you might need customer to acknowledge special shipping requirements for example. So, how do we display an additional tick box on the Checkout page (together with the existing […]
  • WooCommerce: Redirect to Custom Thank you Page
    How can you redirect customers to a beautifully looking, custom, thank you page? Thankfully you can add some PHP code to your functions.php or install a simple plugin and define a redirect to a custom WordPress page (as opposed to the default order-received endpoint). This is a great way for you to add specific up-sells, […]
  • WooCommerce: Disable Payment Gateway by Country
    You might want to disable PayPal for non-local customers or enable a specific gateway for only one country… Either way, this is a very common requirement for all of those who trade internationally. Here’s a simple snippet you can further customize to achieve your objective. Simply pick the payment gateway “slug” you want to disable/enable […]

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza. Follow @rmelogli

20 thoughts on “WooCommerce: Move Order Notes @ Checkout

  1. Hello, I would like to show the comment field only when a new delivery address is selected. After ticking the box “Ship to another Address”.
    Is there a solution for this? Best regards, Fabian

    1. Hi Fabian, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  2. Thank you so much!
    It works amazingly…
    I did a small change in the last function, I share here:

    function bbloomer_custom_field_value_to_order_notes( $order_id, $data ) {
    	if ( ! is_object( $order_id ) ) {
    		$order = wc_get_order( $order_id );
    	}
    	if( $data['new_order_notes'] != '' ){
    		$order->set_customer_note( $data['new_order_notes'] );
    		wc_create_order_note( $order_id, $data['new_order_notes'], true, true );
    		$order->save();
    	}
    }
    

    Otherwise it was saving empty notes with every order!

  3. How to place the order notes field under the payment methods?

    1. Hello Joao, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  4. Hello, I would like to ask you how I can move order comment to the hook position “woocommerce_review_order_before_submit”. Thank you

    1. Hi German, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Thanks for the snippet, but I think you might be conflating/combining the simple ‘Order comments’ text area on the checkout page (that has the id “order_comments”) with the ‘Order notes’ feature available in the back-end after an order is placed. Part 3 of your snippet doesn’t set the order_comments field but instead tries to create a new order note. I’ve taken a snip here if it helps explain it: https://snipboard.io/O6o5ea.jpg

    1. Thank you so much. If you just remove the “wc_create_order_note” line, does it work?

  6. Very good Rodolfo,

    I have verified that now the order notes are not saved in the customer data, they are not added to the order. They only appear in emails, but not in orders.

    Regards!

    1. Thank you Tomas! I find it weird it displays in emails and not in the orders, they come from the same data. Can you try with a different theme and no plugins but Woo?

      1. Hi Rodolfo,

        thanks for your answer. My theme is Storefront. It appears in the email but I assure you that it does not appear in the order data.

        Greetings!

        1. Thank you. I’ve revised the snippet, let me know

          1. Thanks Rodolfo for the inconvenience.
            Still not saved in the order data, however, I receive an additional email with the order notes.
            If nobody else has that problem, I suppose it will be a theme of my website.
            Anyway, thank you very much.
            Regards!!

            1. You’re welcome 🙂

  7. As always – works like a charm! But do not forget about placeholder text 🙂

    'placeholder' => 'some ultra-important description inside textarea',
    

    Greetings!

    1. Awesome!

  8. Hi Rodolfo

    It is a great idea to move the order notes, so it is much better. But it has two forgotten details:
    The first is that there is no placeholder (I have easily solved this).
    The second is that by default, in woocommerce when the customer selects the collection locally, the order notes are hidden, so it is in that location. However, with this code they are not hidden.

    A greeting!

    1. Thank you!

Questions? Feedback? Customization? Leave your comment now!
_____

If you are writing code, please wrap it like so: [php]code_here[/php]. Failure to complying with this, as well as going off topic or not using the English language will result in comment disapproval. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining the Business Bloomer Club to get quick WooCommerce support. Thank you!

Your email address will not be published. Required fields are marked *