Created
March 27, 2023 16:02
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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