B2B Order Prefix — Custom Shopify App | Zain Irfan
Shopify App · Custom App
B2B Order Prefix — Custom Shopify App
A custom Shopify app for a B2B merchant that prefixes only the orders that need it — automatically cancelling and recreating qualifying company orders as #WO-orders, with every detail preserved.
Shopify App
Laravel
Shopify B2B
GraphQL Admin API
Webhooks
Queues

Selective
Prefix where it's needed
Only qualifying B2B company orders get the WO- prefix; every other order is untouched.
Auto
No manual renaming
Orders are checked and recreated automatically as they come in.
Logged
Traceable
Each order's outcome and any error is recorded for the team to review.
The challenge
The client sells both to regular customers and to B2B companies through Shopify. Their team needed wholesale orders from B2B companies to stand out with a WO- prefix (#WO-1052 instead of #1052), so warehouse and accounts could spot them instantly — but every other order had to keep its normal number.
Shopify's built-in order ID prefix doesn't help here: it applies to every order in the store, with no way to target only some of them. And Shopify doesn't allow an order's name to be changed once it has been created, so there was no simple way to rename just the B2B orders after the fact.
What I built
I built a custom Laravel Shopify app that listens for new orders through webhooks and decides, order by order, whether it should be prefixed: the prefix setting must be on, the order must come from a B2B company, the company must not be on the admin's exclusion list, and the order must not be refunded, cancelled or already prefixed.
For qualifying orders, the app saves a complete copy of the order — customer, addresses, line items, discounts, taxes, shipping, company, tags, note and PO number — then cancels the original through the GraphQL Admin API with restocking. A queued job then recreates the order as #WO-1052 with the same details, storing the PO number in a custom metafield. Every step is logged, so any failure can be traced and retried.
What I shipped
Order webhook handling with queued background jobs
Rules engine: prefix on/off, B2B-only and per-company exclusions
Full order snapshot — items, customer, addresses, discounts, taxes, shipping
Order cancellation with restock through the GraphQL Admin API
Recreated #WO- orders with tags, note and PO number metafield
Admin pages for orders, B2B companies and settings inside Shopify
Order sync and filtering for the store's order history
Per-order logs and error tracking
Screenshots

Settings — prefix switch and companies excluded from the prefix

B2B companies synced from Shopify
0 likes · 0 views · Nov 27, 2026
Built a Shopify app that identifies qualifying B2B orders, recreates them with a WO- prefix, and logs each outcome.