Skip to content

Web Orders into the ERP

This scenario takes paid orders from a WooCommerce store into the ERP. It runs as two integrations:

  • the order integration reads the orders waiting for the ERP, skips any the ERP already holds, writes each order, and notes the ERP's order number on the order in WooCommerce;
  • the despatch integration moves each order to completed when the ERP ships it.

Two integrations. The order integration runs a WooCommerce reader on the Orders pull with Status processing, a Filter that drops the orders the ERP already holds, a Map, an ERP writer that creates the sales order, and a WooCommerce writer on the Order Notes push. The despatch integration runs an ERP reader of shipped orders, a Map setting Status to completed, and a WooCommerce writer on the Orders push

The ERP side works with any ERP that IMan writes to. Its own guide covers the writer.

The Order Integration

Read the Orders

A WooCommerce reader on the Orders pull, with Status set to processing. WooCommerce gives an order that status once the customer has paid for it.

The order's billing_ and shipping_ fields carry the addresses the customer entered at checkout, and most integrations need nothing else about the customer. Select the Customer_ fields only if the ERP account needs the details saved on the customer's WooCommerce account. Each customer then costs the run one more request.

While you build the integration, set Orders created in the last to a short span, such as 7d, to keep the Designer's previews small. A scheduled run ignores it.

Skip the Orders the ERP Already Holds

Every run reads every processing order, including the ones earlier runs sent. A Filter drops the orders the ERP already holds. It looks up each order's WooCommerce id in the ERP field where the writer stores it, such as the sales order's customer reference, and keeps only the orders with no match. See Preventing Duplicate Transactions in the Integration Cookbook.

Write the Order

A Map shapes each order for the ERP writer:

  • the ERP customer account, such as one web-sales account, or an account found by billing_email;
  • each OrderItems record as a sales order line, by its sku, with quantity and the line's total and total_tax. Both come after any coupon discount, and the ERP's order total then matches WooCommerce's total;
  • shipping_total and shipping_tax as a carriage charge;
  • the order's WooCommerce id in the reference field the Filter checks. Where a plugin numbers orders differently from their ids, store the number as well, for staff to search by.

The ERP writer creates the sales order. Most ERP writers write the new order's number back onto the record. See the ERP's own guide.

Note the ERP's Order Number

A WooCommerce writer on the Order Notes push, with Update Operation at Insert:

  • Order Id: the order's id;
  • Note: the ERP's order number, such as "Sales order " & %ERPOrderNumber & " created in the ERP";
  • Is Customer Note: False. Only staff see the note.

Staff working in WooCommerce can then find the order in the ERP.

Leave the order's status as it is. Moving it to completed here would send the customer WooCommerce's Completed order email before anything has shipped.

The Despatch Integration

An ERP reader reads the orders the ERP has shipped since its last run, with the WooCommerce order id the order integration stored. A Map sets the status, and a WooCommerce writer on the Orders push, with Update Operation at Update, writes it:

  • Id: the stored WooCommerce id;
  • Status: completed.

WooCommerce sends the customer the Completed order email. The order also leaves the processing orders, and the order integration stops reading it.

Running It

Schedule the order integration as often as orders arrive, such as every 15 minutes. Set its writers' Action on Transform Failure to Reject Record. An order the ERP refuses keeps its processing status and comes back on the next run, and the rest go through.

Schedule the despatch integration after each despatch run in the ERP. Every order that waits in processing comes back on every run of the order integration, only for the Filter to drop it. Keep the despatch integration running, and the orders it reads stay few.