Company checkout
How carts and orders are tied to a company, and who can check out.
Company buyers use the core cart and checkout routes. Waylo Commerce adds rules on top: carts and orders are linked to a company, and only some buyers can check out.
Company carts
- A cart created by a signed-in employee is linked to their company.
- The company always comes from the customer's employee record. Company IDs in the request or in cart
metadataare ignored. - Guest carts and carts of customers without a company have no company.
- Store cart routes return
company.idandcompany.namewhen you ask for them (fields=+company.id,+company.name), so checkout can show who the order is for. Other company fields are never returned on a cart, because anyone with the cart ID can read it.
Who can check out
Customers without a company check out as usual. For company buyers, completing a cart needs all of these:
| Rule | Error |
|---|---|
The buyer is an active employee with the shop permission | permission_denied (403) |
| A company cart belongs to the buyer's own company | permission_denied (403) |
The company is active | company_not_active (400) |
By default owner, admin, and buyer have shop. A viewer, or any employee of a pending or suspended company, can build a cart but can't place the order.
Moving a cart to another customer
A company cart carries that company's prices, so it can only be transferred to an active employee of the same company. Any other customer gets permission_denied with status 400, not 403 as elsewhere. Carts with no company transfer freely.
Orders
- A placed order is linked to the cart's company. If the cart had none (for example a guest cart claimed at sign-in), it gets the buyer's current company, if any.
- Linking happens after
order.placed. It is safe to repeat and never moves an order that already has a company. - A daily job links any order from a cart completed in the last 48 hours that still has no company, to catch any the event missed. See Events and jobs.
- Merchants read an order's company on the admin order route, for example
fields=id,company.id,company.name. - Deleting a company keeps the order link rows, but
order.companythen reads as empty.
Spending limits and order approvals are not built yet. Today the checkout rules are the three above.