- 订单
- 订单可以做什么
- 订单属性
- 终点
- Retrieve all orders
- Retrieve specific orders
- Retrieve orders that have authorized payments ready to be captured
- Retrieve orders last updated after 2005-07-31 15:57:11 in the EDT timezone
- Retrieve all orders but show only certain properties
- Retrieve all orders after the specified ID
- Retrieve a single order
- Get only particular fields
- Count all orders
- Count orders that have authorized payments ready to be captured
- Close an order
- Re-open a closed order
- Cancel an order
- Cancel and refund an order using the
amount
property - When an order has multiple refundable transactions, refunding an amount less than its net payment without a
refund
property fails with an error - Cancel and refund an order using the
refund
property - Canceling an order that has fulfillments fails with an error
- Create a simple order with only a product variant ID
- Create a simple order, sending an order confirmation and a shipping confirmation to the customer
- Create a simple order without sending an order receipt or a fulfillment receipt
- Create a simple order and fulfill it
- Create a comprehensive order
- Create an order with tax lines split across taxable line items
- Creating an order with tax lines both on line items and on the order fails and returns an error
- Create a pending order with an existing customer
- Create a partially paid order with a new customer and addresses
- Create an order and apply a discount
- Add a note to order
- Add note attributes to an order
- Change an order’s email address
- Change an order’s phone number
- Change whether the buyer accepts marketing
- Add a metafield to an order
- Update the shipping address of an order
- Remove the customer from an order
- Update an order’s tags
- Delete an order
订单
订单是客户从商店购买一种或多种产品的完整请求。当客户完成结帐过程时,将创建一个订单,在此期间,他们提供电子邮件地址或电话号码,账单地址和付款信息。
可以通过API创建订单,但不会收集付款信息,也不会执行任何交易。您可以将订单标记为任何付款状态。
您还可以允许商家使用DraftOrder资源手动创建订单。
警告
您不能使用Order资源为单个商店创建新的结帐。要创建结帐,您需要使用Checkout API或由Storefront API提供支持的SDK ,例如JavaScript Buy SDK,iOS Buy SDK或Android Buy SDK。
警告
截至2018年6月6日,默认情况下,只能从`订单''资源访问商店中最后60天的订单价值。如果要访问旧订单,则需要[请求访问所有订单](https://shopify.dev/tutorials/authenticate-a-public-app-with-oauth#orders-permissions)。如果您的应用被授予访问权限,则可以将
read_all_orders范围与
read_orders或一起添加到您的应用中
write_orders`。 私有应用不受此更改的影响,并自动获得范围。
创建订单后,您只能使用API更改其一些属性。您无法使用REST API更改订单中的项目或数量,但可以使用GraphQL Admin API更改它们或数量。
订单资源不会暴露商户在订单上购买的运输标签或成本。
您也可以将元字段添加到“订单”资源。
订单可以做什么
Shopify API允许您对Order资源执行以下操作。这些常规操作的更详细的版本可能可用:
- GET /admin/api/2021-01/orders.json?status=any检索订单列表
- GET /admin/api/2021-01/orders/{order_id}.json检索特定订单
- GET /admin/api/2021-01/orders/count.json检索订单数
- POST /admin/api/2021-01/orders/{order_id}/close.json关闭订单
- POST /admin/api/2021-01/orders/{order_id}/open.json重新打开未结订单
- POST /admin/api/2021-01/orders/{order_id}/cancel.json取消订单
- POST /admin/api/2021-01/orders.json创建订单
- PUT /admin/api/2021-01/orders/{order_id}.json更新订单
- 删除/admin/api/2021-01/orders/{order_id}.json删除订单
订单属性
app_id 只读 | plain "app_id": 1966818 创建订单的应用的ID。 |
---|---|
帐单地址 | plain "billing_address": { "address1": "2259 Park Ct", "address2": "Apartment 5", "city": "Drayton Valley", "company": null, "country": "Canada", "first_name": "Christopher", "last_name": "Gorski", "phone": "(555)555-5555", "province": "Alberta", "zip": "T0E 0M0", "name": "Christopher Gorski", "province_code": "AB", "country_code": "CA", "latitude": "45.41634", "longitude": "-75.6868" } 与付款方式关联的邮寄地址。该地址是一个可选字段,在不需要付款方式的订单上将不可用。它具有以下属性:+ address1:帐单地址的街道地址。 + address2:帐单地址的街道地址的可选附加字段。 + city:帐单邮寄地址的城市,城镇或村庄。 + company:与帐单地址相关联的人的公司。 + country:帐单邮寄地址所在国家/地区的名称。 + country_code:帐单邮寄地址所在国家/地区的两个字母的代码(ISO 3166-1格式)。 + first_name:与付款方式相关联的人员的名字。 + last_name:与付款方式相关联的人员的姓氏。 + latitude:帐单地址的纬度。 + 经度:帐单地址的经度。 + name:与付款方式相关联的人的全名。 + 电话:帐单地址上的电话号码。 + province:帐单邮寄地址的地区名称(省,州,州,…)。 + province_code:帐单邮寄地址的区域的两个字母的缩写。 + zip:帐单邮寄地址的邮政编码(邮政编码,邮政编码,Eircode等)。 |
browser_ip 只读 | plain "browser_ip": "216.191.105.146" 客户下订单时使用的浏览器的IP地址。 |
Buyer_accepts_marketing | plain "buyer_accepts_marketing": false 客户是否同意从商店接收电子邮件更新。 |
cancel_reason | plain "cancel_reason": "customer" 订单被取消的原因。有效值:+ 客户:客户取消了订单。 + 欺诈:订单是欺诈性的。 + 库存:订单中的商品不在库存中。 + 拒绝:付款被拒绝。 + 其他:不在此列表中的原因。 |
cancelled_at 只读 | plain "cancelled_at": null 取消订单的日期和时间(ISO 8601格式)。 |
cart_token 只读 | plain "cart_token": "68778783ad298f1c80c3bafcddeea" 与订单关联的购物车的ID。 |
checkout_token 只读 | plain "checkout_token": "bd5a8aa1ecd019dd3520ff791ee3a24c" 与订单关联的结帐ID。 |
client_details 只读 | plain "client_details": { "accept_language": "en-US,en;q=0.9", "browser_height": 1320, "browser_ip": "216.191.105.146", "browser_width": 1280, "session_hash": "9ad4d1f4e6a8977b9dd98eed1e477643", "user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36" } 有关客户下订单时使用的浏览器的信息:+ accept_language:浏览器可以理解的语言和语言环境。 + browser_height:浏览器屏幕高度(以像素为单位)(如果有)。 + browser_ip:浏览器IP地址。 + browser_width:以像素为单位的浏览器屏幕宽度(如果有)。 + session_hash:会话的哈希。 + user_agent:浏览客户端的详细信息,包括软件和操作版本。 |
close_at 只读 | plain "closed_at": "2008-01-10T11:00:00-05:00" 订单关闭的日期和时间(ISO 8601格式)。 |
created_at 只读 | plain "created_at": "2008-01-10T11:00:00-05:00" 在Shopify中创建订单时的自动生成的日期和时间(ISO 8601格式)。此属性的值无法更改。 |
货币 | plain "currency": "USD" 商店货币的三个字母的代码(ISO 4217格式)。 |
current_total_discounts 只读 | plain "current_total_discounts": "10.00" 当前以商店货币表示的订单总折扣。该字段的值反映了订单编辑,退货和退款。 |
current_total_discounts_set 只读 | plain "current_total_discounts_set": { "shop_money": { "amount": "10.00", "currency_code": "CAD" }, "presentment_money": { "amount": "5.00", "currency_code": "EUR" } } 当前订单上商店和展示货币的总折扣。amount 与该字段关联的值反映了订单编辑,退货和退款。 |
current_total_duties_set 只读 | plain "current_total_duties_set": { "shop_money": { "amount": "164.86", "currency_code": "CAD" }, "presentment_money": { "amount": "105.31", "currency_code": "EUR" } } 当前以商店和演示货币对订单收取的总关税。amount 与该字段关联的值反映了订单编辑,退货和退款。 |
current_total_price 只读 | plain "current_total_price": "10.00" 订单当前的总价(以商店货币计)。该字段的值反映了订单编辑,退货和退款。 |
current_total_price_set 只读 | plain "current_total_price_set": { "shop_money": { "amount": "30.00", "currency_code": "CAD" }, "presentment_money": { "amount": "20.00", "currency_code": "EUR" } } 订单当前的总价,以商店和演示货币表示。amount 与该字段关联的值反映了订单编辑,退货和退款。 |
current_subtotal_price 只读 | plain "current_subtotal_price": "10.00" 以商店货币表示的订单的当前小计价格。该字段的值反映了订单编辑,退货和退款。 |
current_subtotal_price_set 只读 | plain "current_subtotal_price_set": { "shop_money": { "amount": "30.00", "currency_code": "CAD" }, "presentment_money": { "amount": "20.00", "currency_code": "EUR" } } 商店和展示货币中订单的当前小计价格。amount 与该字段关联的值反映了订单编辑,退货和退款。 |
current_total_tax 只读 | plain "current_total_tax": "10.00" 当前以商店货币对订单收取的总税额。该字段的值反映了订单编辑,退货或退款。 |
current_total_tax_set 只读 | plain "current_total_tax_set": { "shop_money": { "amount": "30.00", "currency_code": "CAD" }, "presentment_money": { "amount": "20.00", "currency_code": "EUR" } } 当前以商店和演示货币对订单收取的总税款。amount 与该字段关联的值反映了订单编辑,退货和退款。 |
顾客 | plain "customer": { "id": 207119551, "email": "bob.norman@hostmail.com", "accepts_marketing": false, "created_at": "2012-03-13T16:09:55-04:00", "updated_at": "2012-03-13T16:09:55-04:00", "first_name": "Bob", "last_name": "Norman", "orders_count": "1", "state": "disabled", "total_spent": "0.00", "last_order_id": 450789469, "note": null, "verified_email": true, "multipass_identifier": null, "tax_exempt": false, "tax_exemptions": {}, "phone": "+13125551212", "tags": "loyal", "last_order_name": "#1001", "currency": "USD", "addresses": {}, "admin_graphql_api_id": "gid://shopify/Customer/207119551", "default_address": {} } 有关客户的信息。该订单可能没有客户,并且应用程序不应依赖于customer 对象的存在。null 如果订单是通过Shopify POS创建的,则此值为。有关该customer 对象的更多信息,请参见客户资源。 |
customer_locale 只读 | plain "customer_locale": "en-CA" 两个或三个字母的语言代码,可以选择后面跟一个区域修饰符。 |
discount_applications 只读 | plain "discount_applications": [ { "type": "manual", "title": "custom discount", "description": "customer deserved it", "value": "2.0", "value_type": "fixed_amount", "allocation_method": "across", "target_selection": "explicit", "target_type": "line_item" }, { "type": "script", "description": "my scripted discount", "value": "5.0", "value_type": "fixed_amount", "allocation_method": "across", "target_selection": "explicit", "target_type": "shipping_line" }, { "type": "discount_code", "code": "SUMMERSALE", "value": "10.0", "value_type": "fixed_amount", "allocation_method": "across", "target_selection": "all", "target_type": "line_item" } ] 堆叠折扣应用程序的有序列表。所述 discount_applications 属性包括3种类型:discount_code ,manual ,和script 。所有这三种类型都具有相同的结构,并具有某些类型特定的属性。+ location_method:将折扣应用程序值分配给已授权行的方法。有效值: + 警告 + across :该值分布在所有授权行中。+ each :该值应用于所有授权行。+ one :该值应用于一行。+ 从2020-07版本开始, across 返回而不是,one 因为显式折扣的含义相同。+ code:用于应用折扣的折扣代码。仅适用于折扣代码应用程序。 + description:折扣应用程序的描述,由商人或Shopify脚本定义。仅适用于手动和脚本折扣应用程序。 + target_selection: The lines on the order, of the type defined by target_type , that the discount is allocated over. Valid values:+ all : The discount is allocated onto all lines,+ entitled : The discount is allocated only onto lines it is entitled for.+ explicit : The discount is allocated onto explicitly selected lines.+ target_type: The type of line on the order that the discount is applicable on. Valid values: + line_item : The discount applies to line items.+ shipping_line : The discount applies to shipping lines.+ title: The title of the discount application, as defined by the merchant. Available only for manual discount applications. + type:折扣应用程序类型。有效值: + automatic :折扣是自动应用的,例如“买X送Y”的自动折扣。+ discount_code :折扣由折扣代码应用。+ manual :折扣是由商家手动应用的(例如,通过使用应用或创建草稿订单)。+ script :折扣是由Shopify脚本应用的。+ value:折扣应用程序的值(以十进制表示)。这代表了折扣申请的意图。例如,如果意图是应用20%的折扣,则值将为 20.0 。如果打算进行$ 15的折扣,则价值为15.0 。+ value_type:值的类型。有效值: + fixed_amount :定额折扣值,以订单货币表示。+ percentage :百分比折扣值。 |
Discount_codes | plain "discount_codes": [ { "code": "SPRING30", "amount": "30.00", "type": "fixed_amount" } ] 应用于订单的折扣列表。每个折扣对象都包含以下属性:+ 金额:从订单总额中扣除的金额。创建订单时,此值是要扣除的百分比或金额。创建订单后,此属性返回计算的金额。 + code:当关联的折扣应用程序为type时 code ,此属性返回在结帐时输入的折扣代码。否则,此属性返回所应用折扣的标题。+ type:折扣的类型。默认值: fixed_amount 。有效值:+ fixed_amount :amount 以商店货币单位应用。例如,如果amount 值为30,而商店的货币为USD,则应用折扣时将从订单总额中扣除30 USD。+ percentage :应用折扣,amount 占订单总额的百分比。+ shipping :对运费小于或等于的订单应用免费送货折扣amount 。例如,如果amount 为30,则折扣将为客户提供小于或等于$ 30的任何运费的免费送货服务。 |
电子邮件 | plain "email": "bob.norman@hostmail.com" 客户的电子邮件地址。 |
financial_status | plain "financial_status": "authorized" 与订单相关的付款状态。只能在创建订单时设置。有效值:+ 未决:付款未决。在这种状态下付款可能会失败。再次检查以确认付款是否已成功支付。 + 已授权:付款已被授权。 + partially_paid: The order have been partially paid. + paid: The payments have been paid. + partially_refunded: The payments have been partially refunded. + refunded: The payments have been refunded. + voided: The payments have been voided. |
fulfillments | plain "fulfillments": [ { "created_at": "2012-03-13T16:09:54-04:00", "id": 255858046, "order_id": 450789469, "status": "failure", "tracking_company": "USPS", "tracking_number": "1Z2345", "updated_at": "2012-05-01T14:22:25-04:00" } ] A list of fulfillments associated with the order. For more information, see the Fulfillment API. |
fulfillment_status | plain "fulfillment_status": "partial" The order’s status in terms of fulfilled line items. Valid values:+ fulfilled: Every line item in the order has been fulfilled. + null: None of the line items in the order have been fulfilled. + 不完整:订单中至少有一个订单项已得到满足。 + 重新库存:订单中的每个订单项都已重新库存,并且订单已取消。 |
网关 不推荐使用 | plain "gateway": "shopify_payments" 使用的支付网关。请改用交易资源。 |
ID 只读 | plain "id": 450789469 订单的ID,用于API。这与order_number 属性不同,属性是商店所有者和客户使用的ID。” |
landing_site 只读 | plain "landing_site": "http://www.example.com?source=abc" 买方进入商店时到达的页面页面的URL。 |
line_items 必需的 | plain "line_items": [ { "fulfillable_quantity": 1, "fulfillment_service": "amazon", "fulfillment_status": "fulfilled", "grams": 500, "id": 669751112, "price": "199.99", "product_id": 7513594, "quantity": 1, "requires_shipping": true, "sku": "IPOD-342-N", "title": "IPod Nano", "variant_id": 4264112, "variant_title": "Pink", "vendor": "Apple", "name": "IPod Nano - Pink", "gift_card": false, "price_set": { "shop_money": { "amount": "199.99", "currency_code": "USD" }, "presentment_money": { "amount": "173.30", "currency_code": "EUR" } }, "properties": [ { "name": "custom engraving", "value": "Happy Birthday Mom!" } ], "taxable": true, "tax_lines": [ { "title": "HST", "price": "25.81", "price_set": { "shop_money": { "amount": "25.81", "currency_code": "USD" }, "presentment_money": { "amount": "20.15", "currency_code": "EUR" } }, "rate": 0.13 } ], "total_discount": "5.00", "total_discount_set": { "shop_money": { "amount": "5.00", "currency_code": "USD" }, "presentment_money": { "amount": "4.30", "currency_code": "EUR" } }, "discount_allocations": [ { "amount": "5.00", "discount_application_index": 2, "amount_set": { "shop_money": { "amount": "5.00", "currency_code": "USD" }, "presentment_money": { "amount": "3.96", "currency_code": "EUR" } } } ], "origin_location": { "id": 1390592786454, "country_code": "CA", "province_code": "ON", "name": "Apple", "address1": "700 West Georgia Street", "address2": "1500", "city": "Toronto", "zip": "V7Y 1G5" }, "duties": [ { "id": "2", "harmonized_system_code": "520300", "country_code_of_origin": "CA", "shop_money": { "amount": "164.86", "currency_code": "CAD" }, "presentment_money": { "amount": "105.31", "currency_code": "EUR" }, "tax_lines": [ { "title": "VAT", "price": "16.486", "rate": 0.1, "price_set": { "shop_money": { "amount": "16.486", "currency_code": "CAD" }, "presentment_money": { "amount": "10.531", "currency_code": "EUR" } } } ], "admin_graphql_api_id": "gid://shopify/Duty/2" } ] } ] 订单项对象的列表,每个对象都包含有关订单中项目的信息。每个对象都具有以下属性:+ fulfulable_quantity:可满足的数量,计算如下: plain quantity - max(refunded_quantity, fulfilled_quantity) - pending_fulfilled_quantity - open_fulfilled_quantity + fulfillment_service:正在履行项目的服务提供商。有效值:manual 或提供程序的名称,例如amazon 或shipwire 。+ fulfillment_status:订单项在订单项中完成的距离。有效值: null ,fulfilled ,partial ,和not_eligible 。+ 克:项目的重量,以克为单位。 + id: The ID of the line item. + price: The price of the item before discounts have been applied in the shop currency. + price_set: The price of the line item in shop and presentment currencies. + product_id: The ID of the product that the line item belongs to. Can be null if the original product associated with the order is deleted at a later date.+ quantity: The number of items that were purchased. + requires_shipping: Whether the item requires shipping. + sku: The item’s SKU (stock keeping unit). + title: The title of the product. + variant_id: The ID of the product variant. + variant_title: The title of the product variant. + vendor: The name of the item’s supplier. + name: The name of the product variant. + gift_card: Whether the item is a gift card. If true , then the item is not taxed or considered for shipping charges.+ properties: An array of custom information for the item that has been added to the cart. Often used to provide product customization options. For more information, see The line_item object. + taxable: Whether the item was taxable. + tax_lines: A list of tax line objects, each of which details a tax applied to the item. + title : The name of the tax.+ price : The amount added to the order for this tax in the shop currency.+ price_set : The amount added to the order for this tax in shop and presentment currencies.+ rate : The tax rate applied to the order to calculate the tax price.+ tip_payment_gateway: The payment gateway used to tender the tip, such as shopify_payments . Present only on tips.+ tip_payment_method: The payment method used to tender the tip, such as Visa . Present only on tips.+ total_discount: The total amount of the discount allocated to the line item in the shop currency. This field must be explictly set using draft orders, Shopify scripts, or the API. Instead of using this field, Shopify recommends using discount_allocations , which provides the same information.+ total_discount_set:以演示币种分配给订单项的总金额。Shopify建议不要使用此字段,而使用 discount_allocations 提供相同的信息。+ discount_allocations:折扣应用程序分配的金额的有序列表。每个折扣分配都与特定的折扣应用程序相关。 + amount :以商店货币分配给该行的折扣金额。+ discount_application_index :相关折扣应用程序在订单discount_applications 列表中的索引。+ amount_set :以商店和演示货币分配给订单项的折扣金额。+ origin_location:订单项的实现来源的位置。 + id :订单项的实现来源的位置ID。Shopify用于计算适用的税金。这不是下订单位置的ID。您可以使用FulfillmentOrder资源来确定商品的来源位置。+ country_code :商品供应商所在国家/地区的两个字母的代码(ISO 3166-1格式)。+ province_code :商品供应商所在地区的两个字母的缩写。+ name :项目供应商的名称。+ address1 :商品供应商的街道地址。+ address2 :商品供应商的套房编号。+ city :项目供应商所在的城市。+ zip :项目供应商的邮政编码。+ 职责:职责对象列表,每个对象包含有关订单项职责的信息。 |
location_id | plain "location_id": 49202758 处理订单的实际位置的ID。此属性是指POS位置。location_id 将始终设置null 为在线订单。如果需要根据订单引用位置,请使用FulfillmentOrder资源。 |
姓名 | plain "name": "#1001" 订单名称,是通过将该order_number 属性与商家常规设置中设置的订单前缀和后缀组合而生成的。这与id 属性(API所使用的订单的ID )不同。API也可以将此字段设置为任何字符串值。 |
笔记 | plain "note": "Customer changed their mind." 店主可以附加到订单的可选注释。 |
note_attributes | plain "note_attributes": [ { "name": "custom name", "value": "custom value" } ] 添加到订单的其他信息。出现在订单详细信息页面的“其他详细信息”部分。每个数组条目必须包含带有name 和value 键的哈希。 |
数字 只读 | plain "number": 1 订单在商店订单计数中的位置。数字是连续的,从1开始。 |
订单号 只读 | plain "order_number": 1001 商店中订单的数量(从1001开始)。订单编号是连续的,从1001开始。 |
original_total_duties_set 只读 | plain "original_total_duties_set": { "shop_money": { "amount": "164.86", "currency_code": "CAD" }, "presentment_money": { "amount": "105.31", "currency_code": "EUR" } } 按商店和演示货币对订单收取的原始总关税。 |
付款详情 不推荐使用 | plain "payment_details": { "avs_result_code": "Y", "credit_card_bin": "453600", "cvv_result_code": "M", "credit_card_number": "•••• •••• •••• 4242", "credit_card_company": "Visa" } 包含有关付款信息的对象。它具有以下属性:+ avs_result_code:来自地址验证系统(AVS)的响应代码。该代码是一个字母。有关代码及其定义,请参见此图表。 + credit_card_bin: The issuer identification number (IIN), formerly known as the bank identification number (BIN), of the customer’s credit card. This is made up of the first few digits of the credit card number. + credit_card_company: The name of the company who issued the customer’s credit card. + credit_card_number: The customer’s credit card number, with most of the leading digits redacted. + cvv_result_code: The response code from the credit card company indicating whether the customer entered the card security code (card verification value) correctly. The code is a single letter or empty string. See this chart for the codes and their definitions. Use the Transaction resource instead. |
payment_gateway_names READ-ONLY | plain "payment_gateway_names": [ "authorize_net", "Cash on Delivery (COD)" ] The list of payment gateways used for the order. |
phone | plain "phone": "+557734881234" The customer’s phone number for receiving SMS notifications. |
presentment_currency | plain "presentment_currency": "CAD" The presentment currency that was used to display prices to the customer. |
processed_at | plain "processed_at": "2008-01-10T11:00:00-05:00" The date and time (ISO 8601 format) when an order was processed. This value is the date that appears on your orders and that’s used in the analytic reports. By default, it matches the created_at value. If you’re importing orders from an app or another platform, then you can set processed_at to a date and time in the past to match when the original order was created. |
processing_method READ-ONLY | plain "processing_method": "direct" How the payment was processed. It has the following valid values:+ checkout: The order was processed using the Shopify checkout. + direct: The order was processed using a direct payment provider. + 手动:使用手动付款方式处理订单。 + 场外:订单已由外部付款提供商处理到Shopify结帐处。 + express:使用PayPal Express Checkout处理订单。 + free:使用折扣代码将订单作为免费订单处理。 |
referring_site | plain "referring_site": "http://www.anexample.com" 客户单击商店链接的网站。 |
退款 只读 | plain "refunds": [ { "id": 18423447608, "order_id": 394481795128, "created_at": "2018-03-06T09:35:37-05:00", "note": null, "user_id": null, "processed_at": "2018-03-06T09:35:37-05:00", "refund_line_items": [], "transactions": [], "order_adjustments": [] } ] 应用于订单的退款清单。有关更多信息,请参阅Refund API。 |
收件地址 | plain "shipping_address": { "address1": "123 Amoebobacterieae St", "address2": "", "city": "Ottawa", "company": null, "country": "Canada", "first_name": "Bob", "last_name": "Bobsen", "latitude": "45.41634", "longitude": "-75.6868", "phone": "555-625-1199", "province": "Ontario", "zip": "K2P0V6", "name": "Bob Bobsen", "country_code": "CA", "province_code": "ON" } The mailing address to where the order will be shipped. This address is optional and will not be available on orders that do not require shipping. It has the following properties:+ address1: The street address of the shipping address. + address2: An optional additional field for the street address of the shipping address. + city: The city, town, or village of the shipping address. + company: The company of the person associated with the shipping address. + country: The name of the country of the shipping address. + country_code: The two-letter code (ISO 3166-1 format) for the country of the shipping address. + first_name:与送货地址相关联的人员的名字。 + last_name:与送货地址相关联的人员的姓氏。 + latitude:送货地址的纬度。 + 经度:送货地址的经度。 + name:与付款方式相关联的人的全名。 + phone:送货地址上的电话号码。 + province:送货地址的地区名称(省,州,州,…)。 + province_code:送货地址所在区域的两个字母的缩写。 + zip:送货地址的邮政编码(邮政编码,邮政编码,Eircode…)。 |
shipping_lines | plain "shipping_lines": [ { "code": "INT.TP", "price": "4.00", "price_set": { "shop_money": { "amount": "4.00", "currency_code": "USD" }, "presentment_money": { "amount": "3.17", "currency_code": "EUR" } }, "discounted_price": "4.00", "discounted_price_set": { "shop_money": { "amount": "4.00", "currency_code": "USD" }, "presentment_money": { "amount": "3.17", "currency_code": "EUR" } }, "source": "canada_post", "title": "Small Packet International Air", "tax_lines": [], "carrier_identifier": "third_party_carrier_identifier", "requested_fulfillment_service_id": "third_party_fulfillment_service_id" } ] 对象数组,每个对象详细说明所使用的运输方法。每个对象都具有以下属性:+ code:运输方式的参考。 + discounted_price:应用行级折扣后的送货方式价格。不反映购物车级别或订单级别的折扣。 + Discounted_price_set:应用行级折扣后,以商店和演示货币表示的送货方式价格。 + price:此运输方式的价格(以商店货币为单位)。不能为负。 + price_set:以商店和演示货币表示的运输方式的价格。 + source:送货方式的来源。 + title: The title of the shipping method. + tax_lines: A list of tax line objects, each of which details a tax applicable to this shipping line. + carrier_identifier: A reference to the carrier service that provided the rate. Present when the rate was computed by a third-party carrier service. + requested_fulfillment_service_id: A reference to the fulfillment service that is being requested for the shipping method. Present if the shipping method requires processing by a third party fulfillment service; null otherwise. |
source_name | plain "source_name": "web" Where the order originated. Can be set only during order creation, and is not writeable afterwards. Values for Shopify channels are protected and cannot be assigned by other API clients: web , pos , shopify_draft_order , iphone , and android . Orders created via the API can be assigned any other string of your choice. If unspecified, then new orders are assigned the value of your app’s ID. |
subtotal_price | plain "subtotal_price": 398.0 The price of the order in the shop currency after discounts but before shipping, taxes, and tips. |
subtotal_price_set | plain "subtotal_price_set": { "shop_money": { "amount": "141.99", "currency_code": "CAD" }, "presentment_money": { "amount": "90.95", "currency_code": "EUR" } } The subtotal of the order in shop and presentment currencies. |
tags | plain "tags": "imported" Tags attached to the order, formatted as a string of comma-separated values. Tags are additional short descriptors, commonly used for filtering and searching. Each individual tag is limited to 40 characters in length. |
tax_lines | plain "tax_lines": [ { "price": 11.94, "rate": 0.06, "title": "State Tax" } ] An array of tax line objects, each of which details a tax applicable to the order. Each object has the following properties:+ price: The amount of tax to be charged in the shop currency. + rate: The rate of tax to be applied. + title: The name of the tax. When creating an order through the API, tax lines can be specified on the order or the line items but not both. Tax lines specified on the order are split across the taxable line items in the created order. |
taxes_included | plain "taxes_included": false Whether taxes are included in the order subtotal. |
test | plain "test": true Whether this is a test order. |
token READ-ONLY | plain "token": "b1946ac92492d2347c6235b4d2611184" A unique token for the order. |
total_discounts | plain "total_discounts": "0.00" The total discounts applied to the price of the order in the shop currency. |
total_discounts_set | plain "total_discounts_set": { "shop_money": { "amount": "0.00", "currency_code": "CAD" }, "presentment_money": { "amount": "0.00", "currency_code": "EUR" } } The total discounts applied to the price of the order in shop and presentment currencies. |
total_line_items_price | plain "total_line_items_price": "398.00" The sum of all line item prices in the shop currency. |
total_line_items_price_set | plain "total_line_items_price_set": { "shop_money": { "amount": "141.99", "currency_code": "CAD" }, "presentment_money": { "amount": "90.95", "currency_code": "EUR" } } The total of all line item prices in shop and presentment currencies. |
total_outstanding | plain "total_outstanding": "5.00" The total outstanding amount of the order in the shop currency. |
total_price | plain "total_price": "409.94" 所有订单项价格,折扣,运费,税费和商店货币小费的总和。必须是积极的。 |
total_price_set | plain "total_price_set": { "shop_money": { "amount": "164.86", "currency_code": "CAD" }, "presentment_money": { "amount": "105.31", "currency_code": "EUR" } } 订单的总价(以商店和演示货币表示)。 |
total_shipping_price_set | plain "total_shipping_price_set": { "shop_money": { "amount": "30.00", "currency_code": "USD" }, "presentment_money": { "amount": "0.00", "currency_code": "USD" } } 订单的总运输价格,不包括折扣和退货,以商店和演示货币表示。如果taxes_included 设置为true ,则total_shipping_price_set 含税。 |
total_tax | plain "total_tax": "11.94" 以商店货币计入订单的所有税金之和。必须为正数)。 |
total_tax_set | plain "total_tax_set": { "shop_money": { "amount": "18.87", "currency_code": "CAD" }, "presentment_money": { "amount": "11.82", "currency_code": "EUR" } } 以商店和演示货币应用于订单的总税额。 |
total_tip_received 只读 | plain "total_tip_received": "4.87" 订单中所有小费的总和(以商店货币计)。 |
总重量 | plain "total_weight": 300 所有订单项权重的总和(以克为单位)。 |
Updated_at 只读 | plain "updated_at": "2012-08-24T14:02:15-04:00" 上次修改订单的日期和时间(ISO 8601格式)。筛选订单依据 updated_at 不是获取订单的有效方法,因为在未更新订单的可见字段时,其值可能会更改。而是使用Webhook和Event API订阅订单事件。 |
用户身份 | plain "user_id": 31522279 登录到Shopify POS并处理订单的用户的ID(如果有)。 |
order_status_url 只读 | plain "order_status_url": "https://checkout.shopify.com/112233/checkouts/4207896aad57dfb159/thank_you_token?key=753621327b9e8a64789651bf221dfe35" 指向订单状态网页的URL (如果适用)。 |
终点
得到/admin/api/2021-01/orders.json?status=any Retrieves a list of orders. Note: As of version 2019-10, this endpoint implements pagination by using links that are provided in the response header. Sending the<font style="background-color:#F4F6F8;">page</font>
parameter will return an error. To learn more, see Making requests to paginated REST Admin API endpoints.
ids | Retrieve only orders specified by a comma-separated list of order IDs. |
---|---|
limit | The maximum number of results to show on a page. (default: 50 , maximum: 250 ) |
since_id | Show orders after the specified ID. |
created_at_min | Show orders created at or after date (format: 2014-04-25T16:15:47-04:00). |
created_at_max | Show orders created at or before date (format: 2014-04-25T16:15:47-04:00). |
updated_at_min | Show orders last updated at or after date (format: 2014-04-25T16:15:47-04:00). |
updated_at_max | Show orders last updated at or before date (format: 2014-04-25T16:15:47-04:00). |
processed_at_min | Show orders imported at or after date (format: 2014-04-25T16:15:47-04:00). |
processed_at_max | Show orders imported at or before date (format: 2014-04-25T16:15:47-04:00). |
attribution_app_id | Show orders attributed to a certain app, specified by the app ID. Set as current to show orders for the app currently consuming the API. |
status | Filter orders by their status. (default: open ) + open: Show only open orders. + closed: Show only closed orders. + cancelled: Show only canceled orders. + any: Show orders of any status, including archived orders. |
financial_status | Filter orders by their financial status. (default: any ) + authorized: Show only authorized orders + pending: Show only pending orders + paid: Show only paid orders + partially_paid: Show only partially paid orders + refunded: Show only refunded orders + voided: Show only voided orders + partially_refunded: Show only partially refunded orders + any: Show orders of any financial status. + unpaid: Show authorized and partially paid orders. |
fulfillment_status | Filter orders by their fulfillment status. (default: any ) + shipped: Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled .+ partial: Show partially shipped orders. + unshipped: Show orders that have not yet been shipped. Returns orders with fulfillment_status of null .+ any: Show orders of any fulfillment status. + unfulfilled: Returns orders with fulfillment_status of null or partial . |
fields | Retrieve only certain fields, specified by a comma-separated list of fields names. |
Retrieve all orders
GET /admin/api/2021-01/orders.json?status=any
Retrieve specific orders
GET /admin/api/2021-01/orders.json?ids=1073459963
Retrieve orders that have authorized payments ready to be captured
GET /admin/api/2021-01/orders.json?financial_status=authorized
Retrieve orders last updated after 2005-07-31 15:57:11 in the EDT timezone
GET /admin/api/2021-01/orders.json?updated_at_min=2005-07-31T15:57:11-04:00
Retrieve all orders but show only certain properties
GET /admin/api/2021-01/orders.json?fields=created_at,id,name,total-price
Retrieve all orders after the specified ID
GET /admin/api/2021-01/orders.json?since_id=123
GET/admin/api/2021-01/orders/{order_id}.json Retrieves a specific orderfields | Retrieve only certain fields, specified by a comma-separated list of fields names. |
---|---|
Retrieve a single order
GET /admin/api/2021-01/orders/450789469.json
Get only particular fields
GET /admin/api/2021-01/orders/450789469.json?fields=id,line_items,name,total_price
GET/admin/api/2021-01/orders/count.json Retrieves an order countcreated_at_min | Count orders created after date (format: 2014-04-25T16:15:47-04:00). |
---|---|
created_at_max | Count orders created before date (format: 2014-04-25T16:15:47-04:00). |
updated_at_min | Count orders last updated after date (format: 2014-04-25T16:15:47-04:00). |
updated_at_max | Count orders last updated before date (format: 2014-04-25T16:15:47-04:00). |
status | Count orders of a given status. (default: open ) + open: Count open orders. + closed: Count closed orders. + any: Count orders of any status. |
financial_status | Count orders of a given financial status. (default: any ) + authorized: Count authorized orders. + pending: Count pending orders. + paid: Count paid orders. + refunded: Count refunded orders. + voided: Count voided orders. + any: Count orders of any financial status. |
fulfillment_status | Filter orders by their fulfillment status. (default: any ) + shipped: Show orders that have been shipped. Returns orders with fulfillment_status of fulfilled .+ partial: Show partially shipped orders. + unshipped: Show orders that have not yet been shipped. Returns orders with fulfillment_status of null .+ any: Show orders of any fulfillment status. + unfulfilled: Returns orders with fulfillment_status of null or partial . |
Count all orders
GET /admin/api/2021-01/orders/count.json
Count orders that have authorized payments ready to be captured
GET /admin/api/2021-01/orders/count.json?financial_status=authorized
POST/admin/api/2021-01/orders/{order_id}/close.json Closes an orderClose an order
POST /admin/api/2021-01/orders/450789469/close.json
{
}
POST/admin/api/2021-01/orders/{order_id}/open.json Re-opens a closed orderRe-open a closed order
POST /admin/api/2021-01/orders/450789469/open.json
{
}
POST/admin/api/2021-01/orders/{order_id}/cancel.jsonCaution
For multi-currency orders, the currency
property is required whenever the amount
property is provided. For more information, see Migrating to support multiple currencies.
Cancels an order. Orders that have a fulfillment object can’t be canceled.
amount | The amount to refund. If set, Shopify attempts to void or refund the payment, depending on its status. Shopify refunds through a manual gateway in cases where the original transaction was not made in Shopify. Refunds through a manual gateway are recorded as a refund on Shopify, but the customer is not refunded. |
---|---|
currency | The currency of the refund that’s issued when the order is canceled. Required for multi-currency orders whenever the amount property is provided. |
restock DEPRECATED | Whether to restock refunded items back to your store’s inventory. (default: false ) |
reason | The reason for the order cancellation. Valid values: customer , inventory , fraud , declined , and other .)(default: other ) |
Whether to send an email to the customer notifying them of the cancellation. (default: false ) |
|
refund | The refund transactions to perform. Required for some more complex refund situations. For more information, see the Refund API. |
Cancel an order
POST /admin/api/2021-01/orders/450789469/cancel.json
{
}
Cancel and refund an order using the amount
property
POST /admin/api/2021-01/orders/450789469/cancel.json
{
“amount”: “10.00”,
“currency”: “USD”
}
When an order has multiple refundable transactions, refunding an amount less than its net payment without a refund
property fails with an error
POST /admin/api/2021-01/orders/450789469/cancel.json
{
“amount”: “109.00”,
“currency”: “USD”
}
Cancel and refund an order using the refund
property
POST /admin/api/2021-01/orders/450789469/cancel.json
{
“refund”: {
"note": "Customer made a mistake",
"shipping": {
"full_refund": true
},
"refund_line_items": [
{
"line_item_id": 466157049,
"quantity": 1,
"restock_type": "cancel",
"location_id": 48752903
}
],
"transactions": [
{
"parent_id": 1072844672,
"amount": "10.00",
"kind": "refund",
"gateway": "bogus"
},
{
"parent_id": 1072844673,
"amount": "100.00",
"kind": "refund",
"gateway": "gift_card"
}
]
}
}
Canceling an order that has fulfillments fails with an error
POST /admin/api/2021-01/orders/450789469/cancel.json
{
}
POST/admin/api/2021-01/orders.jsonCreates an order. By default, product inventory is not claimed.
When you create an order, you can include the following option parameters in the body of the request:
- inventory_behaviour: The behaviour to use when updating inventory. (default:
bypass
)- bypass: Do not claim inventory.
- decrement_ignoring_policy: Ignore the product’s inventory policy and claim inventory.
- decrement_obeying_policy: Follow the product’s inventory policy and claim inventory, if possible.
- send_receipt: Whether to send an order confirmation to the customer.
Note
If you’re working on a private app and order confirmations are still being sent to the customer when send_receipt
is set to false
, then you need to disable the Storefront API from the private app’s page in the Shopify admin.
- send_fulfillment_receipt: Whether to send a shipping confirmation to the customer.
Note
If you are including shipping_address or billing_address, make sure to pass both first_name and last_name. Otherwise both these addresses will be ignored.
If you’re using this endpoint with a trial or Partner development store, then you can create no more than 5 new orders per minute.
Create a simple order with only a product variant ID
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
]
}
}
Create a simple order, sending an order confirmation and a shipping confirmation to the customer
POST /admin/api/2021-01/orders.json
{
“order”: {
"email": "foo@example.com",
"fulfillment_status": "fulfilled",
"send_receipt": true,
"send_fulfillment_receipt": true,
"line_items": [
{
"variant_id": 457924702,
"quantity": 1
}
]
}
}
Create a simple order without sending an order receipt or a fulfillment receipt
POST /admin/api/2021-01/orders.json
{
“order”: {
"email": "foo@example.com",
"fulfillment_status": "fulfilled",
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
]
}
}
Create a simple order and fulfill it
POST /admin/api/2021-01/orders.json
{
“order”: {
"email": "foo@example.com",
"fulfillment_status": "fulfilled",
"fulfillments": [
{
"location_id": 48752903
}
],
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
]
}
}
Create a comprehensive order
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"title": "Big Brown Bear Boots",
"price": 74.99,
"grams": "1300",
"quantity": 3,
"tax_lines": [
{
"price": 13.5,
"rate": 0.06,
"title": "State tax"
}
]
}
],
"transactions": [
{
"kind": "sale",
"status": "success",
"amount": 238.47
}
],
"total_tax": 13.5,
"currency": "EUR"
}
}
Create an order with tax lines split across taxable line items
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"title": "Red Leather Coat",
"price": 129.99,
"grams": "1700",
"quantity": 1
},
{
"title": "Blue Suede Shoes",
"price": 85.95,
"grams": "750",
"quantity": 1,
"taxable": false
},
{
"title": "Raspberry Beret",
"price": 19.99,
"grams": "320",
"quantity": 2
}
],
"tax_lines": [
{
"price": 10.2,
"rate": 0.06,
"title": "State tax"
},
{
"price": 4.25,
"rate": 0.025,
"title": "County tax"
}
],
"total_tax": 14.45
}
}
Creating an order with tax lines both on line items and on the order fails and returns an error
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"title": "Clicky Keyboard",
"price": 99.99,
"grams": "600",
"quantity": 1,
"tax_lines": [
{
"price": 1.0,
"rate": 0.01,
"title": "Keyboard tax"
}
]
}
],
"tax_lines": [
{
"price": 6.0,
"rate": 0.06,
"title": "State tax"
}
]
}
}
Create a pending order with an existing customer
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
],
"customer": {
"id": 207119551
},
"financial_status": "pending"
}
}
Create a partially paid order with a new customer and addresses
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
],
"customer": {
"first_name": "Paul",
"last_name": "Norman",
"email": "paul.norman@example.com"
},
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "123 Fake Street",
"phone": "555-555-5555",
"city": "Fakecity",
"province": "Ontario",
"country": "Canada",
"zip": "K2P 1L4"
},
"shipping_address": {
"first_name": "Jane",
"last_name": "Smith",
"address1": "123 Fake Street",
"phone": "777-777-7777",
"city": "Fakecity",
"province": "Ontario",
"country": "Canada",
"zip": "K2P 1L4"
},
"email": "jane@example.com",
"transactions": [
{
"kind": "authorization",
"status": "success",
"amount": 50.0
}
],
"financial_status": "partially_paid"
}
}
Create an order and apply a discount
POST /admin/api/2021-01/orders.json
{
“order”: {
"line_items": [
{
"variant_id": 447654529,
"quantity": 1
}
],
"email": "jane@example.com",
"phone": "18885551234",
"billing_address": {
"first_name": "John",
"last_name": "Smith",
"address1": "123 Fake Street",
"phone": "555-555-5555",
"city": "Fakecity",
"province": "Ontario",
"country": "Canada",
"zip": "K2P 1L4"
},
"shipping_address": {
"first_name": "Jane",
"last_name": "Smith",
"address1": "123 Fake Street",
"phone": "777-777-7777",
"city": "Fakecity",
"province": "Ontario",
"country": "Canada",
"zip": "K2P 1L4"
},
"transactions": [
{
"kind": "sale",
"status": "success",
"amount": 50.0
}
],
"financial_status": "paid",
"discount_codes": [
{
"code": "FAKE30",
"amount": "9.00",
"type": "percentage"
}
]
}
}
PUT/admin/api/2021-01/orders/{order_id}.json Updates an orderAdd a note to order
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"note": "Customer contacted us about a custom engraving on this iPod"
}
}
Add note attributes to an order
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"note_attributes": [
{
"name": "colour",
"value": "red"
}
]
}
}
Change an order’s email address
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"email": "a-different@email.com"
}
}
Change an order’s phone number
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"phone": "+15145556677"
}
}
Change whether the buyer accepts marketing
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"buyer_accepts_marketing": true
}
}
Add a metafield to an order
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"metafields": [
{
"key": "new",
"value": "newvalue",
"value_type": "string",
"namespace": "global"
}
]
}
}
Update the shipping address of an order
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"shipping_address": {
"address1": "123 Ship Street",
"city": "Shipsville"
}
}
}
Remove the customer from an order
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"customer": null
}
}
Update an order’s tags
PUT /admin/api/2021-01/orders/450789469.json
{
“order”: {
"id": 450789469,
"tags": "External, Inbound, Outbound"
}
}
DELETE/admin/api/2021-01/orders/{order_id}.json Deletes an order. Orders that interact with an online gateway can’t be deleted.Delete an order
DELETE /admin/api/2021-01/orders/450789469.json