I'm trying to change the WooCommerce order prefix based on user roles, Currently, this function work flawlessly :
add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number' );
function change_woocommerce_order_number( $order_id ) {
$prefix = 'WHLS';
$new_order_id = $prefix . $order_id;
return $new_order_id;
}
Now, I'm trying to change the order prefix based on user roles in the following way: Export/Distributor Gold - GLD-### (new) Export/Distributor Silver - SLVR-### (new) Wholesale - WHLS-### (current functionality)
My attempted code: (This function code does not add any prefix to the orders number).
add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number' );
function change_woocommerce_order_number( $order_id ) {
if ( current_user_can( 'wholeseller' ))
$prefix = 'WHLS';
$new_order_id = $prefix . $order_id;
return $new_order_id;
}
if ( current_user_can( 'distributor_gold' )) {
$prefix = 'GLD';
$new_order_id = $prefix . $order_id;
return $new_order_id;
}
elseif ( current_user_can( 'distributor_silver' )) {
$prefix = 'SLVR';
$new_order_id = $prefix . $order_id;
return $new_order_id;
}
Anyone can point me in the right direction?