How to Add a Prefix/Suffix to B2B / B2C Order Numbers or Split B2B / B2C Orders

Table of Contents

By default, B2BKing adds a B2B column to the Orders page, allowing to easily know which orders are B2B:

Note: For this to work, the plugin plugin must be set to "B2B & B2C Hybrid Shop" in B2BKing -> Settings -> Main Settings.

However, you may want to also change the order numbers. Here's what you need to know.

Change Order Number #

You may want to differentiate between B2B and B2C orders via order number if you are running a hybrid site. Here is a simple code snippet that can do it.

// Add Prefix to Orders by B2B
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);
	if ($order){
		$customer_id = $order->get_customer_id();
		$customer_b2b = get_user_meta($customer_id,'b2bking_b2buser', true);
		if ($customer_b2b === 'yes'){
		    $prefix = 'PRO-';
	            $suffix = '';
		    $order_id = $prefix . $order_id . $suffix;
	return $order_id;

This code adds "PRO-" to all orders of B2B customers.

Here's what that looks like in practice in the backend.

This is a simple way to differentiate between orders and it can be useful in many scenarios, especially for delivery and order fulfillment.

Powered by BetterDocs