Production orders from an online store
Before you start
You will build the link between an online shop and a kitchen, a workshop or a factory floor. A Shopify order arrives in Beezr as it is placed. Each line becomes a production job that knows its recipe. When a job is done, its materials come off stock. When a material falls below its reorder level, a purchase request opens before the shelf is empty. Plan on a day, and test each workflow with one order before you trust it.
- Shopify order
- Webhook
- Production job
- Materials deducted
- Low stock
- Purchase request
What are we building?
Section titled “What are we building?”A webhook workflow on an Orders module receives the order. A second workflow runs when a job is finished and deducts materials. A third raises the purchase request. The shop stays where it is. Beezr does the work after the sale.
Which modules and fields?
Section titled “Which modules and fields?”| Module | Key fields | Notes |
|---|---|---|
| Products | Name, SKU, Product type | Product type: Single, Bundle. The SKU is what the store sends |
| Materials | Name, Unit, Stock on hand, Reorder level | Stock on hand and Reorder level are Decimal fields |
| Recipe Lines | Product, Material, Quantity per unit | Product and Material are relations |
| Orders | Shopify order ID, Order number, Customer name, Total, Status | Shopify order ID is Text |
| Production Jobs | Order, Product, Quantity, Status | Status: Planned, In production, Done |
| Waste Logs | Job, Material, Quantity, Reason | Reason is a Lookup |
| Purchase Requests | Material, Quantity needed, Status | Status: Open, Ordered, Received |
Make the relations with the Relation button on each module’s Fields page: Recipe Lines to Products and Materials, Production Jobs to Orders and Products, Waste Logs to Production Jobs and Materials, Purchase Requests to Materials. See Relations: how modules connect.
On the Production Jobs form, show the job’s order, product and quantity. On Dataviews, give Production Jobs a Kanban grouped by Status, so the floor can drag a job from Planned to In production to Done. A job without a Status never shows on the board, so set a default of Planned.
How does the order arrive?
Section titled “How does the order arrive?”Create a workflow on Orders, name it Receive Shopify order, and under When should it run? choose From a webhook.
api-key header.Open the workflow’s menu, choose Copy webhook URL, and register that address in Shopify as the webhook for order creation. The webhook accepts JSON. It answers 202 with a run ID when it accepts the call, 400 when the workflow is off or the address is wrong, and 401 when a key is required and missing.
If your Shopify setup can send an api-key header, turn on Require an API key. If it cannot, keep the webhook address private, like a password.
How is the order read and filed?
Section titled “How is the order read and filed?”- Add JSON parser. Choose The data the webhook sent. Under Its shape, add
id,name,total_priceand a List calledline_itemswithskuandquantityinside it. Name the resultshopify_order. - Add Load data. Choose Orders, with the rule Shopify order ID is the parsed
id. Name the listexisting. - Add Decision. Pick the list
existingitself and choose has no records. On No, the order is a repeat, so the workflow ends. - On Yes, add Record manager: Create, Orders. Fill Shopify order ID, Order number, Total with Insert data.
- Add Loop. Choose Each record in a list and pick
line_items. - Inside the loop, add Load data: Products where SKU is the current item’s
sku. Name itproduct. - Still inside, add Record manager: Create, Production Jobs. Set Product to the product’s key, Quantity to the item’s
quantity, Order to the order created, Status to Planned.
List every field you need under Its shape, because those are the fields later steps can use. Give a Number field only numbers. The parser reads one JSON object, which is what Shopify sends. A record the Record manager creates is available to later steps by its module, so step 7 can read the order from step 4.
Run Check, save, and turn the workflow on. Send a test order from Shopify, then open the workflow’s Runs to see each step. If the run stops, read A workflow didn’t run.
Shopify can retry a delivery, and nothing in Beezr knows it is the same order. That is why steps 2 and 3 exist.
How do materials come off stock?
Section titled “How do materials come off stock?”Create a workflow on Production Jobs. Run it when A record is updated, After the record is saved (POST). Name it Deduct materials.
- Add Decision: Status is Done. A POST workflow runs on every update, so this keeps it to one moment.
- Add Load data: Recipe Lines where Product is the job’s product. Name it
recipe. - Add Loop, Each record in a list,
recipe. - Inside, add Load data: Materials where the key is the recipe line’s Material. Name it
material. - Add Record manager: Update, Materials. Use the material’s key as Record ID. Set Stock on hand with a Smart Script.
- Add Decision: Stock on hand (on Materials) is less than the Smart Script
$cm_materials_base$.$reorder_level$. On Yes, add Record manager: Create, Purchase Requests, with Status Open.
The script in step 5 follows the number conventions: full tokens, and parseFloat around each value with no quotes.
parseFloat($material$.$stock_on_hand$) - parseFloat($recipe$.$quantity_per_unit$) * parseFloat($cm_production_jobs_base$.$quantity$);Insert each token with Insert data, so the module table name matches yours. The Decision in step 6 reads the material that step 5 has updated, because an updated record is placed in the workflow’s data under its module.
How do I see what is low?
Section titled “How do I see what is low?”The purchase request is the alert. Give Purchase Requests a Table and a Kanban grouped by Status, and add the module to the buyer’s menu. Add a Smart view header with the material, the quantity needed and the status. To be told, add a Send email to the buyer inside the Yes path of step 6.
How is waste recorded?
Section titled “How is waste recorded?”Floor staff add Waste Logs records from the job’s record page, with a Quantity and a Reason from a lookup. Add the Waste Logs module as a related tab of Production Jobs. A report that groups waste by reason and sums the quantity shows where losses come from. See Build a report.
What can I change?
Section titled “What can I change?”- Bundles. For a Product type of Bundle, add a Bundle Components module and a Decision on the product type. On Yes, load the components and loop over them, creating a job for each.
- Dispatch manifest. An Adhoc workflow with a Smart document step prints the manifest from the order. Start it from a Dispatch action button on the Orders record page. See Smart document.
- Fulfilment back to the store. A REST API step at the end of dispatch can post the tracking number to the shop’s API.
- Other stores. The same pattern works for any system that can send JSON to a URL. See Start a workflow from another system with a webhook.
Where can I read the story?
Section titled “Where can I read the story?”The Solutions page follows one Shopify order to dispatch: Production and inventory.
Check yourself
What's next
Last checked