Waylo Commerce
B2B

Events and jobs

The events the B2B plugins emit and the scheduled jobs they run.

The B2B plugins emit events on the backend's event bus, next to the core commerce events. Subscribe to them in your own plugin to react to company changes.

Payloads

Payloads carry IDs only. Read the current state from the API when you handle an event. New fields may be added within a version, so ignore fields you don't know. Each event has a JSON Schema in the repo under docs/specs/events.

Company events

EventPayloadWhen
company.createdidA merchant created a company, or a buyer signed one up.
company.updatedidA company's details, status, or settings overrides changed, by a merchant or a buyer.
company.approvedidA pending company became active. company.updated is emitted too.
company.deletedidA company was deleted. employee.removed is emitted for each employee too.
employee.createdid, company_idA customer became an active employee, including the owner at signup.
employee.updatedid, company_idAn employee's role changed.
employee.removedid, company_idAn employee was removed, their company was deleted, or their customer account was deleted. The customer account stays in the first two cases.

Address changes emit no events.

{ "id": "emp_01JB2X7QA1", "company_id": "comp_01JB2X7Q8R" }

Settings events

b2b-setting.updated carries keys, the setting keys that changed. It is in the contract for POST /admin/b2b-settings, which isn't served yet, so nothing emits it today.

Scheduled jobs

JobScheduleWhat it does
reconcile-order-companiesDaily at 03:00 (cron 0 3 * * *)Links any order from a cart completed in the last 48 hours that still has no company. A safety net for the order.placed subscriber.

The job only adds missing links. It never changes an order that already has a company. Set COMPANY_ORDER_RECONCILE=false in the backend's environment to turn it off. See Carts and checkout for how orders get their company.

On this page