Comments 1low weihao started the conversationApril 15, 2021 at 1:38amHi Stefan ,i had just saw your document site there got code that can be add prefix word in front of order for b2b or b2c ,can i use it specific for some user role or group 2,219WebWizards repliedApril 15, 2021 at 6:27pmHi Glendon, Yes, you can do that. Some examples: 1) Show for every order, the user's group as prefix: add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number' ); function change_woocommerce_order_number( $order_id ) { // get if customer is B2B $order = wc_get_order($order_id); $customer_id = $order->get_customer_id(); $customer_b2b = get_user_meta($customer_id,'b2bking_b2buser', true); if ($customer_b2b === 'yes'){ $customer_group = get_user_meta($customer_id,'b2bking_customergroup', true); $title = get_the_title($customer_group); $prefix = $title.'-'; $suffix = ''; $order_id = $prefix . $order_id . $suffix; } return $order_id; } Looks like: 2) Show Prefix only for VIP Group (VIP group has ID 27): add_filter( 'woocommerce_order_number', 'change_woocommerce_order_number' ); function change_woocommerce_order_number( $order_id ) { // get if customer is B2B $order = wc_get_order($order_id); $customer_id = $order->get_customer_id(); $customer_b2b = get_user_meta($customer_id,'b2bking_b2buser', true); $customer_group = get_user_meta($customer_id,'b2bking_customergroup', true); if ($customer_b2b === 'yes' && $customer_group == 27){ $prefix = 'PRO'.'-'; $suffix = ''; $order_id = $prefix . $order_id . $suffix; } return $order_id; } Kind regards,Stefan Sign in to reply ...
Hi Stefan ,i had just saw your document site there got code that can be add prefix word in front of order for b2b or b2c ,can i use it specific for some user role or group
Hi Glendon,
Yes, you can do that.
Some examples:
1) Show for every order, the user's group as prefix:
Looks like:
2) Show Prefix only for VIP Group (VIP group has ID 27):
Kind regards,
Stefan