Orders¶
The Orders pull reads the store's orders, for a sales order or invoice in the target system. Each order carries its billing and shipping addresses, totals, coupons, fees, shipping and taxes, with a line for each item beneath it. Each order also carries the details of the registered customer who placed it.
On a reader, select Orders as the WooCommerce Entity.
Reader Options¶
| Option | Effect |
|---|---|
| Status | The statuses to read, separated by commas, such as processing,on-hold. WooCommerce's own statuses are pending, processing, on-hold, completed, cancelled, refunded, failed and trash, and a store's plugins can add more. Leave it empty to read every status. |
| Customer/Order Meta Fields | The meta data keys to read from each order, separated by commas. See Meta Data. |
| Order Line Meta Fields | The meta data keys to read from each line. |
| Orders created in the last | Limits a preview in the Designer to the orders created in a recent span. See below. |
Orders created in the last¶
A preview or refresh in the Designer reads only the orders created in this span. Use it to keep a preview small on a store with many orders. Write a number followed by a unit:
| Unit | Meaning | Example |
|---|---|---|
d |
days | 1d, or 0.5d for 12 hours |
h |
hours | 12h |
m |
minutes | 30m |
s |
seconds | 90s |
A run outside the Designer ignores the option and reads every order with the chosen statuses. Leave it empty to preview every such order.
Choosing the Orders a Run Reads¶
The pull keeps no date of its last run. Each run reads every order whose status is in Status, oldest first, 100 orders to a request. An order comes in on every run until its status changes. Build the integration so it handles each order once, in one of two ways.
Skip the orders the ERP already has. Read the orders waiting for the ERP, such as processing. Before writing each one, check the ERP for the WooCommerce order number, and drop the orders it already holds. When an order ships, move it to completed with the Orders push. This suits a store that ships physical goods, and the Web Orders into the ERP scenario builds it.
Move each order out of the statuses the reader reads. Once the ERP has the order, change its status with the Orders push, and the next run leaves it out. Choose the new status with care:
- A status a plugin adds, such as
exported, usually means nothing to the customer. WooCommerce's own statuses have no "in the ERP" status. completedtells WooCommerce the order is fulfilled, and sends the customer the Completed order email. Use it at this point only where nothing ships, such as for digital goods.
An order whose write fails keeps its status either way, and the next run tries it again. See Preventing Duplicate Transactions in the Integration Cookbook for the ERP-side check.
Records¶
The pull returns an Order record for each order, with an OrderItems record for each line item.
Order¶
id, WooCommerce's id for the order, andnumber, the order number the customer sees. The two are often the same, but a plugin can change the number;status,currency,prices_include_tax,payment_method,payment_method_titleandtransaction_id;customer_id,customer_noteandcreated_via;- the
billing_andshipping_address fields, such asbilling_email,billing_postcodeandshipping_country; discount_total,discount_tax,shipping_total,shipping_tax,cart_tax,totalandtotal_tax;date_created,date_modified,date_paidanddate_completed, each in the store's time zone, with a_gmtfield in UTC beside it.
OrderItems¶
id,product_id,variation_idandsku.variation_idis0for a simple product;name,quantityandprice;subtotalandsubtotal_tax, before discounts, andtotalandtotal_tax, after them;tax_class.
Coupons, Fees, Shipping and Taxes¶
WooCommerce returns these as lists. The pull spreads the first few of each across numbered fields on the Order record:
| Fields | Holds | Each one has |
|---|---|---|
coupon_1_ to coupon_3_ |
the first three coupons used | id, code, discount and discount_tax |
fee_1_ to fee_3_ |
the first three fees | id, name, amount, total, total_tax, tax_class and tax_status, with each fee's first two taxes |
shipping_line_1_ and shipping_line_2_ |
the first two shipping methods | id, method_id, method_title, instance_id, total and total_tax, with each line's first two taxes |
tax_line_1_ and tax_line_2_ |
the first two tax rates on the order | id, rate_code, rate_id, label, compound, tax_total and shipping_tax_total |
Each OrderItems record has tax_line_1_ and tax_line_2_, with the line's first two taxes.
An order with more than three coupons or fees, or more than two shipping lines or tax rates, loses the rest. The order's own totals still include them. Check discount_total, shipping_total and total_tax against the numbered fields where that matters.
Meta Data¶
Plugins store their own values on an order, such as a delivery date or a VAT number, as meta data: a list of keys and values. The pull reads the keys you name:
- each key in Customer/Order Meta Fields becomes a field of the same name on the Order record;
- each key in Order Line Meta Fields becomes a field of the same name on the OrderItems record.
A field holds the value of the first meta data entry with that key. To find a plugin's keys, read an order with TRACE on, or ask the plugin's author.
The Customer's Details¶
Fields beginning Customer_ hold the registered customer's own record, as the Customers pull reads it: Customer_email, Customer_first_name, Customer_last_name, Customer_username, Customer_role, Customer_is_paying_customer, the Customer_billing_ and Customer_shipping_ addresses, and the dates. The order's own billing_ and shipping_ fields hold the addresses the customer entered at checkout. The Customer_ fields hold the addresses saved on the account, and the two can differ.
The customer's record takes a request of its own:
- The pull fetches customers only when the reader's fields include at least one
Customer_field. Leave them out, and the pull sends no customer requests. - It fetches each customer once in a run, however many orders the customer placed.
- A guest order, with
customer_id0, has no customer. ItsCustomer_fields stay empty. - A customer deleted from the store leaves the fields empty too.
- A customer the store fails to return leaves the fields empty, and the audit log records a warning naming the order's
customer_id. The order still comes in.
Each key in Customer/Order Meta Fields also becomes a Customer_ field, such as Customer_vat_number, holding the customer's own meta data value for that key.
WooCommerce Reference¶
Orders in the WooCommerce REST API documentation.