WooCommerce Order Number Prefix and Suffix

To change the WooCommerce order number to include a prefix and suffix, add the following code to the functions.php file in the theme directory that you use on your installation. To change the prefix or suffix, modify the variables $prefix and $suffix respectively.

add_filter( 'woocommerce_order_number', 'wpdesk_woocommerce_order_number_prefix_suffix', 20 );
function wpdesk_woocommerce_order_number_prefix_suffix( $order_id ) {
    $prefix = 'X/';
    $suffix = '/Y';
    $new_order_id = $prefix . $order_id . $suffix;
    return $new_order_id;
}

View the code on Gist.

If you do not use the child theme, remember that changes made to the functions.php file will be overwritten when the theme is updated.

While copying code to functions.php file it is not nessesary to copy <?php opening tag.

About grola

Passionate about Wordpress and WooCommerce for many years. Author of plugins and short snippets improving Wordpress and WooCommerce.

View all posts by grola →