B2B Checkout Mode
B2B mode adds business-specific fields to the checkout form: company name, VAT number with real-time validation, purchase order (PO) number, and configurable payment terms. All collected data is stored as order meta in WooCommerce.
Enabling B2B mode
Section titled “Enabling B2B mode”Pass b2b: true when creating a session:
curl -X POST https://api.swft.co.uk/v1/sessions \ -H "Authorization: Bearer $SWFT_API_KEY" \ -H "Content-Type: application/json" \ -d '{ "cart": { "b2b": true, "lineItems": [...] } }'You can also enable it globally for a merchant so every session defaults to B2B mode:
curl -X PATCH https://api.swft.co.uk/v1/merchants/{id} \ -H "Authorization: Bearer $SWFT_API_KEY" \ -H "Content-Type: application/json" \ -d '{"defaults": {"b2b": true}}'Fields added in B2B mode
Section titled “Fields added in B2B mode”| Field | Required | Notes |
|---|---|---|
| Company name | Yes | Stored as _billing_company on the order |
| VAT number | No | Validated in real time; stored as _swft_vat_number |
| PO number | No | Free text; stored as _swft_po_number |
| Payment terms | No | Shown if paymentTerms options are configured |
Company name
Section titled “Company name”Replaces the standard “First name / Last name” row with “Company name” plus a condensed name row beneath it. The contact name is still collected for order fulfilment purposes.
VAT number
Section titled “VAT number”The VAT field appears below the company name. As the shopper types, Swft validates the number format client-side using a country-code prefix regex before triggering a live lookup.
VAT validation
Section titled “VAT validation”Swft validates VAT numbers against two authoritative sources depending on the country prefix:
EU member states — validated via the VIES SOAP API. A valid VIES response returns the registered business name, which is shown to the shopper as confirmation. If VIES is temporarily unavailable (it has planned downtime windows), validation is skipped and the number is accepted with a warning flag stored on the order.
GB (post-Brexit) — validated via the HMRC VAT number API. The same confirmation name display applies.
Other countries — format validation only (no live lookup). The number is stored as entered.
When a valid VAT number is confirmed, the checkout automatically removes VAT from the order total if the merchant’s WooCommerce store has the “EU VAT Assistant” or “WooCommerce EU VAT Number” plugin installed and configured for zero-rating B2B sales. This is handled via the swft_session_tax_override filter.
add_filter( 'swft_session_tax_override', function( $tax, $session ) { if ( $session['b2b']['vatValid'] && $session['b2b']['vatCountry'] !== 'GB' ) { return 0; // zero-rate validated EU business customers } return $tax;}, 10, 2 );PO number
Section titled “PO number”An optional free-text field for the customer’s internal purchase order reference. Stored as _swft_po_number on the WooCommerce order and displayed in the order confirmation email if the swft_order_email_po_number filter returns true.
Payment terms
Section titled “Payment terms”Configure available terms in the merchant config:
{ "b2b": { "paymentTerms": [ { "label": "Pay now", "value": "immediate", "default": true }, { "label": "Net 14", "value": "net14" }, { "label": "Net 30", "value": "net30" } ] }}When paymentTerms is configured, a selector appears in the checkout. Selecting a deferred term (anything other than immediate) skips the card step and places the order with the WooCommerce status on-hold. Your accounts team or an automation (e.g. WooCommerce Subscriptions, Xero integration) is then responsible for collecting payment.
The selected term is stored as _swft_payment_terms on the order.
WooCommerce order meta
Section titled “WooCommerce order meta”A completed B2B order carries the following additional meta:
| Meta key | Value |
|---|---|
_billing_company | Company name as entered |
_swft_vat_number | VAT number string |
_swft_vat_valid | 1 if VIES/HMRC confirmed, 0 otherwise |
_swft_vat_country | ISO 3166-1 alpha-2 country code of the VAT number |
_swft_vat_name | Registered business name returned by VIES/HMRC |
_swft_po_number | Purchase order reference |
_swft_payment_terms | Selected payment terms value |