Buy B2BKing
$179 $129
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