Skip to main content

Orders

The orders API allows you to create, view, update, and delete individual, or a batch, of orders.

Order properties

AttributeTypeDescription
idintegerUnique identifier for the resource. READ-ONLY
parent_idintegerParent order ID.
numberstringOrder number. READ-ONLY
order_keystringOrder key. READ-ONLY
created_viastringShows where the order was created. READ-ONLY
versionstringVersion of WooCommerce which last updated the order. READ-ONLY
statusstringOrder status. Options: pending, processing, on-hold, completed, cancelled, refunded, failed and trash. Default is pending.
currencystringCurrency the order was created with, in ISO format. Options: AED, AFN, ALL, AMD, ANG, AOA, ARS, AUD, AWG, AZN, BAM, BBD, BDT, BGN, BHD, BIF, BMD, BND, BOB, BRL, BSD, BTC, BTN, BWP, BYR, BZD, CAD, CDF, CHF, CLP, CNY, COP, CRC, CUC, CUP, CVE, CZK, DJF, DKK, DOP, DZD, EGP, ERN, ETB, EUR, FJD, FKP, GBP, GEL, GGP, GHS, GIP, GMD, GNF, GTQ, GYD, HKD, HNL, HRK, HTG, HUF, IDR, ILS, IMP, INR, IQD, IRR, IRT, ISK, JEP, JMD, JOD, JPY, KES, KGS, KHR, KMF, KPW, KRW, KWD, KYD, KZT, LAK, LBP, LKR, LRD, LSL, LYD, MAD, MDL, MGA, MKD, MMK, MNT, MOP, MRO, MUR, MVR, MWK, MXN, MYR, MZN, NAD, NGN, NIO, NOK, NPR, NZD, OMR, PAB, PEN, PGK, PHP, PKR, PLN, PRB, PYG, QAR, RON, RSD, RUB, RWF, SAR, SBD, SCR, SDG, SEK, SGD, SHP, SLL, SOS, SRD, SSP, STD, SYP, SZL, THB, TJS, TMT, TND, TOP, TRY, TTD, TWD, TZS, UAH, UGX, USD, UYU, UZS, VEF, VND, VUV, WST, XAF, XCD, XOF, XPF, YER, ZAR and ZMW. Default is USD.
date_createddate-timeThe date the order was created, in the site's timezone. READ-ONLY
date_created_gmtdate-timeThe date the order was created, as GMT. READ-ONLY
date_modifieddate-timeThe date the order was last modified, in the site's timezone. READ-ONLY
date_modified_gmtdate-timeThe date the order was last modified, as GMT. READ-ONLY
discount_totalstringTotal discount amount for the order. READ-ONLY
discount_taxstringTotal discount tax amount for the order. READ-ONLY
shipping_totalstringTotal shipping amount for the order. READ-ONLY
shipping_taxstringTotal shipping tax amount for the order. READ-ONLY
cart_taxstringSum of line item taxes only. READ-ONLY
totalstringGrand total. READ-ONLY
total_taxstringSum of all taxes. READ-ONLY
prices_include_taxbooleanTrue the prices included tax during checkout. READ-ONLY
customer_idintegerUser ID who owns the order. 0 for guests. Default is 0.
customer_ip_addressstringCustomer's IP address. READ-ONLY
customer_user_agentstringUser agent of the customer. READ-ONLY
customer_notestringNote left by customer during checkout.
billingobjectBilling address. See Order - Billing properties
shippingobjectShipping address. See Order - Shipping properties
payment_methodstringPayment method ID.
payment_method_titlestringPayment method title.
transaction_idstringUnique transaction ID.
date_paiddate-timeThe date the order was paid, in the site's timezone. READ-ONLY
date_paid_gmtdate-timeThe date the order was paid, as GMT. READ-ONLY
date_completeddate-timeThe date the order was completed, in the site's timezone. READ-ONLY
date_completed_gmtdate-timeThe date the order was completed, as GMT. READ-ONLY
cart_hashstringMD5 hash of cart items to ensure orders are not modified. READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties
line_itemsarrayLine items data. See Order - Line items properties
tax_linesarrayTax lines data. See Order - Tax lines properties READ-ONLY
shipping_linesarrayShipping lines data. See Order - Shipping lines properties
fee_linesarrayFee lines data. See Order - Fee lines properties
coupon_linesarrayCoupons line data. See Order - Coupon lines properties
refundsarrayList of refunds. See Order - Refunds properties READ-ONLY
set_paidbooleanDefine if the order is paid. It will set the status to processing and reduce stock items. Default is false. WRITE-ONLY

Order - Billing properties

AttributeTypeDescription
first_namestringFirst name.
last_namestringLast name.
companystringCompany name.
address_1stringAddress line 1
address_2stringAddress line 2
citystringCity name.
statestringISO code or name of the state, province or district.
postcodestringPostal code.
countrystringCountry code in ISO 3166-1 alpha-2 format.
emailstringEmail address.
phonestringPhone number.

Order - Shipping properties

AttributeTypeDescription
first_namestringFirst name.
last_namestringLast name.
companystringCompany name.
address_1stringAddress line 1
address_2stringAddress line 2
citystringCity name.
statestringISO code or name of the state, province or district.
postcodestringPostal code.
countrystringCountry code in ISO 3166-1 alpha-2 format.

Order - Meta data properties

AttributeTypeDescription
idintegerMeta ID. READ-ONLY
keystringMeta key.
valuestringMeta value.

Order - Line items properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringProduct name.
product_idintegerProduct ID.
variation_idintegerVariation ID, if applicable.
quantityintegerQuantity ordered.
tax_classintegerTax class of product.
subtotalstringLine subtotal (before discounts).
subtotal_taxstringLine subtotal tax (before discounts). READ-ONLY
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order - Taxes properties READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties
skustringProduct SKU. READ-ONLY
pricestringProduct price. READ-ONLY

Order - Tax lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
rate_codestringTax rate code. READ-ONLY
rate_idstringTax rate ID. READ-ONLY
labelstringTax rate label. READ-ONLY
compoundbooleanShow if is a compound tax rate. READ-ONLY
tax_totalstringTax total (not including shipping taxes). READ-ONLY
shipping_tax_totalstringShipping tax total. READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties

Order - Shipping lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
method_titlestringShipping method name.
method_idstringShipping method ID.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order - Taxes properties READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties

Order - Fee lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
namestringFee name.
tax_classstringTax class of fee.
tax_statusstringTax status of fee. Options: taxable and none.
totalstringLine total (after discounts).
total_taxstringLine total tax (after discounts). READ-ONLY
taxesarrayLine taxes. See Order - Taxes properties READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties

Order - Coupon lines properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
codestringCoupon code.
discountstringDiscount total.
discount_taxstringDiscount total tax. READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties

Order - Refunds properties

AttributeTypeDescription
idintegerRefund ID. READ-ONLY
reasonstringRefund reason. READ-ONLY
totalstringRefund total. READ-ONLY

Order - Taxes properties

AttributeTypeDescription
idintegerItem ID. READ-ONLY
rate_codestringTax rate code. READ-ONLY
rate_idstringTax rate ID. READ-ONLY
labelstringTax rate label. READ-ONLY
compoundbooleanShow if is a compound tax rate. READ-ONLY
tax_totalstringTax total (not including shipping taxes). READ-ONLY
shipping_tax_totalstringShipping tax total. READ-ONLY
meta_dataarrayMeta data. See Order - Meta data properties

Create an order

This API helps you to create a new order.

POST /wp-json/wc/v2/orders

Example of create a paid order:

curl -X POST https://example.com/wp-json/wc/v2/orders \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": true,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 93,
"quantity": 2
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "10.00"
}
]
}'

Retrieve an order

This API lets you retrieve and view a specific order.

GET /wp-json/wc/v2/orders/<id>
curl https://example.com/wp-json/wc/v2/orders/727 \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
dpstringNumber of decimal points to use in each resource.

List all orders

This API helps you to view all the orders.

GET /wp-json/wc/v2/orders
curl https://example.com/wp-json/wc/v2/orders \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
contextstringScope under which the request is made; determines fields present in response. Options: view and edit. Default is view.
pageintegerCurrent page of the collection. Default is 1.
per_pageintegerMaximum number of items to be returned in result set. Default is 10.
searchstringLimit results to those matching a string.
afterstringLimit response to resources published after a given ISO8601 compliant date.
beforestringLimit response to resources published before a given ISO8601 compliant date.
dates_are_gmtbooleanInterpret after and before as UTC dates when true.
excludearrayEnsure result set excludes specific IDs.
includearrayLimit result set to specific ids.
offsetintegerOffset the result set by a specific number of items.
orderstringOrder sort attribute ascending or descending. Options: asc and desc. Default is desc.
orderbystringSort collection by object attribute. Options: date, id, include, title and slug. Default is date.
parentarrayLimit result set to those of particular parent IDs.
parent_excludearrayLimit result set to all items except those of a particular parent ID.
statusstringLimit result set to orders assigned a specific status. Options: any, pending, processing, on-hold, completed, cancelled, refunded and failed. Default is any.
customerintegerLimit result set to orders assigned a specific customer.
productintegerLimit result set to orders assigned a specific product.
dpintegerNumber of decimal points to use in each resource. Default is 2.

Update an Order

This API lets you make changes to an order.

HTTP Request

PUT /wp-json/wc/v2/orders/<id>
curl -X PUT https://example.com/wp-json/wc/v2/orders/727 \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"status": "completed"
}'

Delete an order

This API helps you delete an order.

DELETE /wp-json/wc/v2/orders/<id>
curl -X DELETE https://example.com/wp-json/wc/v2/orders/727?force=true \
-u consumer_key:consumer_secret

Available parameters

ParameterTypeDescription
forcestringUse true whether to permanently delete the order, Default is false.

Batch update orders

This API helps you to batch create, update and delete multiple orders.

note

Note: By default it's limited to up to 100 objects to be created, updated or deleted.

POST /wp-json/wc/v2/orders/batch
curl -X POST https://example.com/wp-json/wc/v2/orders/batch \
-u consumer_key:consumer_secret \
-H "Content-Type: application/json" \
-d '{
"create": [
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 79,
"quantity": 1
},
{
"product_id": 93,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "30.00"
}
]
},
{
"payment_method": "bacs",
"payment_method_title": "Direct Bank Transfer",
"set_paid": true,
"billing": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US",
"email": "john.doe@example.com",
"phone": "(555) 555-5555"
},
"shipping": {
"first_name": "John",
"last_name": "Doe",
"address_1": "969 Market",
"address_2": "",
"city": "San Francisco",
"state": "CA",
"postcode": "94103",
"country": "US"
},
"line_items": [
{
"product_id": 22,
"variation_id": 23,
"quantity": 1
},
{
"product_id": 22,
"variation_id": 24,
"quantity": 1
}
],
"shipping_lines": [
{
"method_id": "flat_rate",
"method_title": "Flat Rate",
"total": "20.00"
}
]
}
],
"update": [
{
"id": 727,
"shipping_methods": "Local Delivery"
}
],
"delete": [
723
]
}'