Skip to content

Instantly share code, notes, and snippets.

@InpsydeNiklas
Created March 27, 2023 16:02
Show Gist options
  • Save InpsydeNiklas/b63113b93ebbb303712000321921bc4e to your computer and use it in GitHub Desktop.
Save InpsydeNiklas/b63113b93ebbb303712000321921bc4e to your computer and use it in GitHub Desktop.
(Multisite) Customize WooCommerce order number by adding a prefix based on the current blog ID
<?php
/**
* // functions.php
* Customize order number by adding a prefix based on the current blog ID
*/
add_filter('woocommerce_order_number', 'multisite_change_woocommerce_order_number', 1, 2);
function multisite_change_woocommerce_order_number($order_id, $order) {
$blog_id = get_current_blog_id();
switch ($blog_id) {
case 1:
$prefix = 'PREFIX1-';
break;
case 2:
$prefix = 'PREFIX2-';
break;
case 3:
$prefix = 'PREFIX3-';
break;
default:
$prefix = 'DEFAULT_PREFIX-';
}
return $prefix . $order->get_id();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment