Halloween Sale 15% off Ends in See the plans
PHP

Ready-Made Order Note Templates

Adds a dropdown of saved phrases above the order notes box, such as "Dispatched with Royal Mail" or "Waiting for stock", so staff can add common notes in one click.

Don’t have WPIDE yet? Install it on your site

Code

$wpide_note_templates = array(
    'Dispatched today. Tracking details will follow by email.',
    'Waiting for stock from our supplier; expected within 5 working days.',
    'Customer contacted by phone about delivery.',
    'Address checked and confirmed with the customer.',
);

add_action( 'admin_footer', function () use ( $wpide_note_templates ) {
    $screen = get_current_screen();

    if ( ! $screen || ! function_exists( 'wc_get_page_screen_id' ) || wc_get_page_screen_id( 'shop-order' ) !== $screen->id ) {
        return;
    }
    ?>
    <script>
    ( function () {
        var box = document.getElementById( 'add_order_note' );
        if ( ! box ) { return; }
        var templates = <?php echo wp_json_encode( array_values( $wpide_note_templates ) ); ?>;
        var select = document.createElement( 'select' );
        select.setAttribute( 'aria-label', 'Insert a note template' );
        select.style.width = '100%';
        select.style.marginBottom = '6px';
        select.add( new Option( 'Insert a note template…', '' ) );
        templates.forEach( function ( text ) { select.add( new Option( text, text ) ); } );
        select.addEventListener( 'change', function () {
            if ( select.value ) { box.value = select.value; box.focus(); select.selectedIndex = 0; }
        } );
        box.parentNode.insertBefore( select, box );
    } )();
    </script>
    <?php
} );

Notes

Edit the phrases in $wpide_note_templates; picking one fills the note box and you still choose private or customer note.

How to add this snippet

  1. Install WPIDE on your WordPress site (it is free) and open Code Snippets.
  2. Use snippet above adds it from the library in one click. Or copy the code into a new snippet with the same code type.
  3. It is added inactive: review the code and settings, then switch it on.

Have a snippet worth sharing?

Publish it to the library from WPIDE or right here. Sign in with any WordPress site that runs WPIDE, free or Pro. Public snippets are reviewed by the WPIDE team before they appear.

Which site should get this snippet?

Enter the address of your WordPress site. WPIDE opens there in a new tab with the snippet ready to review and save.

Remembered in this browser only, so you are asked once.

Report this snippet

Tell the WPIDE team what is wrong: broken code, something harmful, spam or copied work.