We built DEV3 AI B2B Wholesale & Quote Requests as a WooCommerce plugin in PHP with a React admin and small dependency-free storefront scripts. It covers both halves of B2B selling and works fully with AI switched off.
Key design decisions
- One pricing engine.
Pricing\Engine::price( $product, $role, $qty ) is called by the cart, product pages, the quick-order table, the quote editor and the AI draft step. Precedence is fixed: a product-level price for the role, then the highest-priority rule (ties go to the lowest price), then the role's default discount. Quantity breaks can switch between percent off, amount off and a fixed unit price.
- Wholesale roles as real WordPress roles. Each tier has its own default discount, minimum order value and quantity, tax exemption, allowed payment gateways and shipping methods, and price label. Minimums and restrictions apply to both the classic and the block checkout.
- Quotes priced by rules, then frozen. New quote lines start at the engine price for the customer's role and quantity; a typed price overrides it, and only Re-price from rules goes back. Lines are stored in the plugin's own tables.
- Accept creates exactly one order. A conditional status update claims the quote before any order exists, so two clicks can't create two orders. The order is built through WooCommerce CRUD with each line's subtotal and total fixed to the quoted amount, shipping as quoted and the discount as a negative fee, then left pending with a pay-for-order link.
- AI that can't invent products or prices. The Google Gemini API sees the request and up to 40 candidate products without prices. Ids outside the candidate list are dropped, prices come from the engine, and nothing is saved until the admin accepts the draft. The same approach writes cover and follow-up emails and screens wholesale applications as advice only.
Architecture
Rules, applications, quotes, quote lines and a quote timeline live in five custom tables; product prices, breaks, visibility, minimum quantity and pack size are product meta. Storefront pieces are shortcodes and blocks: wholesale registration with approval emails, a searchable quick-order table with a paste-a-list box, a quote basket with "Request a quote for this cart", and a customer quote view (My Account or a signed guest link) with Accept, Decline, messages and the PDF. PDF quotes come from a small built-in PDF 1.4 writer, so no PDF library is needed. A daily cron sends one reminder per quote and expires old ones. HPOS and the Cart and Checkout blocks are declared compatible. The API client, settings and usage logs come from a shared core used across DEV3's plugins.