Shopify回传订单

Topic summary

核心问题:Shopify订单回传与发货状态管理

开发者需要通过API获取Shopify订单,完成发货后回传物流信息,并避免重复获取已发货订单。

关键解决方案:

  1. 订单类型区分:不要使用草稿订单(draft orders),应使用正式订单。草稿订单是商家手动创建的定制订单,无法正常履行发货流程。

  2. 测试环境搭建:需创建开发商店(Development Store)来测试,避免购买付费套餐。通过Shopify Partners账户创建开发店铺,可在前台手动下单测试。

  3. API调用流程

    • 获取订单:GET /admin/api/2021-10/orders.json
    • 发货回传:POST /admin/api/2021-10/fulfillments.json(需传入tracking_number、tracking_url、location_id等参数)
    • 筛选已发货订单:使用fulfillment_status=shippedstatus=closed参数
  4. 常见错误

    • "Not Found"错误通常因参数错误,需正确传递fulfillment_order_idline_items
    • 时区问题:API返回时间为UTC+8,需根据实际时区调整查询参数

未解决问题
多位后续开发者遇到相同的参数传递和接口调用问题,讨论仍在持续。

Summarized with AI on November 19. AI used: claude-sonnet-4-5-20250929.

正如您描述的那样,我已经成功的通过开发商店创建到了正式订单,也通过API接口获取到订单集合

请看如下调用接口的示意图和示意代码

1、获取订单集合

https://8578cc2007111d6dff8ea7b92e6fd69f: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@redliuiot.myshopify.com/admin/api/2021-10/orders.json?limi=1

{
“orders”: [
{
“id”: 3897756385380,
“admin_graphql_api_id”: “gid://shopify/Order/3897756385380”,
“app_id”: 1354745,
“browser_ip”: null,
“buyer_accepts_marketing”: false,
“cancel_reason”: null,
“cancelled_at”: null,
“cart_token”: null,
“checkout_id”: 23122729205860,
“checkout_token”: “755bd1f381202b00b53da1501a293cc4”,
“client_details”: {
“accept_language”: null,
“browser_height”: null,
“browser_ip”: null,
“browser_width”: null,
“session_hash”: null,
“user_agent”: null
},
“closed_at”: null,
“confirmed”: true,
“contact_email”: null,
“created_at”: “2021-10-21T17:16:26+08:00”,
“currency”: “USD”,
“current_subtotal_price”: “100.00”,
“current_subtotal_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“current_total_discounts”: “0.00”,
“current_total_discounts_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“current_total_duties_set”: null,
“current_total_price”: “106.63”,
“current_total_price_set”: {
“shop_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
}
},
“current_total_tax”: “6.63”,
“current_total_tax_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“customer_locale”: null,
“device_id”: null,
“discount_codes”: ,
“email”: “”,
“estimated_taxes”: false,
“financial_status”: “paid”,
“fulfillment_status”: null,
“gateway”: “manual”,
“landing_site”: null,
“landing_site_ref”: null,
“location_id”: 61114024036,
“name”: “#1002”,
“note”: null,
“note_attributes”: ,
“number”: 2,
“order_number”: 1002,
“order_status_url”: “https://redliuiot.myshopify.com/55082123364/orders/b928d9759b7f611d3f4b540ef8f93d4b/authenticate?key=ab97f05a96102f5aef85ac6d2d5e601c”,
“original_total_duties_set”: null,
“payment_gateway_names”: [
“manual”
],
“phone”: null,
“presentment_currency”: “USD”,
“processed_at”: “2021-10-21T17:16:26+08:00”,
“processing_method”: “manual”,
“reference”: null,
“referring_site”: null,
“source_identifier”: null,
“source_name”: “shopify_draft_order”,
“source_url”: null,
“subtotal_price”: “100.00”,
“subtotal_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“tags”: “”,
“tax_lines”: [
{
“price”: “6.63”,
“rate”: 0.06625,
“title”: “New Jersey State Tax”,
“price_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“channel_liable”: false
}
],
“taxes_included”: false,
“test”: false,
“token”: “b928d9759b7f611d3f4b540ef8f93d4b”,
“total_discounts”: “0.00”,
“total_discounts_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“total_line_items_price”: “100.00”,
“total_line_items_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“total_outstanding”: “0.00”,
“total_price”: “106.63”,
“total_price_set”: {
“shop_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
}
},
“total_price_usd”: “106.63”,
“total_shipping_price_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“total_tax”: “6.63”,
“total_tax_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“total_tip_received”: “0.00”,
“total_weight”: 45359,
“updated_at”: “2021-10-21T17:16:27+08:00”,
“user_id”: 71512817764,
“discount_applications”: ,
“fulfillments”: ,
“line_items”: [
{
“id”: 10176485720164,
“admin_graphql_api_id”: “gid://shopify/LineItem/10176485720164”,
“fulfillable_quantity”: 1,
“fulfillment_service”: “manual”,
“fulfillment_status”: null,
“gift_card”: false,
“grams”: 45359,
“name”: “HAT - RED”,
“origin_location”: {
“id”: 2973975347300,
“country_code”: “US”,
“province_code”: “NJ”,
“name”: “601 RANDOLPH RD”,
“address1”: “601 RANDOLPH RD”,
“address2”: “”,
“city”: “SOMERSET”,
“zip”: “08873”
},
“price”: “100.00”,
“price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“product_exists”: true,
“product_id”: 6608633462884,
“properties”: ,
“quantity”: 1,
“requires_shipping”: true,
“sku”: “HAT”,
“taxable”: true,
“title”: “HAT”,
“total_discount”: “0.00”,
“total_discount_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“variant_id”: 39453535535204,
“variant_inventory_management”: “shopify”,
“variant_title”: “RED”,
“vendor”: “redliuiot”,
“tax_lines”: [
{
“channel_liable”: false,
“price”: “6.63”,
“price_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“rate”: 0.06625,
“title”: “New Jersey State Tax”
}
],
“duties”: ,
“discount_allocations”:
}
],
“payment_terms”: null,
“refunds”: ,
“shipping_lines”:
},
{
“id”: 3897754452068,
“admin_graphql_api_id”: “gid://shopify/Order/3897754452068”,
“app_id”: 1354745,
“browser_ip”: null,
“buyer_accepts_marketing”: false,
“cancel_reason”: null,
“cancelled_at”: null,
“cart_token”: null,
“checkout_id”: 23122704728164,
“checkout_token”: “ee6bc35bc9b4214d4a0288c2232aa0fb”,
“client_details”: {
“accept_language”: null,
“browser_height”: null,
“browser_ip”: null,
“browser_width”: null,
“session_hash”: null,
“user_agent”: null
},
“closed_at”: null,
“confirmed”: true,
“contact_email”: null,
“created_at”: “2021-10-21T17:12:36+08:00”,
“currency”: “USD”,
“current_subtotal_price”: “100.00”,
“current_subtotal_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“current_total_discounts”: “0.00”,
“current_total_discounts_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“current_total_duties_set”: null,
“current_total_price”: “106.63”,
“current_total_price_set”: {
“shop_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
}
},
“current_total_tax”: “6.63”,
“current_total_tax_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“customer_locale”: null,
“device_id”: null,
“discount_codes”: ,
“email”: “”,
“estimated_taxes”: false,
“financial_status”: “paid”,
“fulfillment_status”: null,
“gateway”: “manual”,
“landing_site”: null,
“landing_site_ref”: null,
“location_id”: 61114024036,
“name”: “#1001”,
“note”: null,
“note_attributes”: ,
“number”: 1,
“order_number”: 1001,
“order_status_url”: “https://redliuiot.myshopify.com/55082123364/orders/ed04787c3fc13d8c39077abfd17b4b21/authenticate?key=ea85995109f6de0fa8b44465927616a5”,
“original_total_duties_set”: null,
“payment_gateway_names”: [
“manual”
],
“phone”: null,
“presentment_currency”: “USD”,
“processed_at”: “2021-10-21T17:12:36+08:00”,
“processing_method”: “manual”,
“reference”: null,
“referring_site”: null,
“source_identifier”: null,
“source_name”: “shopify_draft_order”,
“source_url”: null,
“subtotal_price”: “100.00”,
“subtotal_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“tags”: “”,
“tax_lines”: [
{
“price”: “6.63”,
“rate”: 0.06625,
“title”: “New Jersey State Tax”,
“price_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“channel_liable”: false
}
],
“taxes_included”: false,
“test”: false,
“token”: “ed04787c3fc13d8c39077abfd17b4b21”,
“total_discounts”: “0.00”,
“total_discounts_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“total_line_items_price”: “100.00”,
“total_line_items_price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“total_outstanding”: “0.00”,
“total_price”: “106.63”,
“total_price_set”: {
“shop_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “106.63”,
“currency_code”: “USD”
}
},
“total_price_usd”: “106.63”,
“total_shipping_price_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“total_tax”: “6.63”,
“total_tax_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“total_tip_received”: “0.00”,
“total_weight”: 45359,
“updated_at”: “2021-10-21T17:12:37+08:00”,
“user_id”: 71512817764,
“discount_applications”: ,
“fulfillments”: ,
“line_items”: [
{
“id”: 10176482803812,
“admin_graphql_api_id”: “gid://shopify/LineItem/10176482803812”,
“fulfillable_quantity”: 1,
“fulfillment_service”: “manual”,
“fulfillment_status”: null,
“gift_card”: false,
“grams”: 45359,
“name”: “HAT - RED”,
“origin_location”: {
“id”: 2973975347300,
“country_code”: “US”,
“province_code”: “NJ”,
“name”: “601 RANDOLPH RD”,
“address1”: “601 RANDOLPH RD”,
“address2”: “”,
“city”: “SOMERSET”,
“zip”: “08873”
},
“price”: “100.00”,
“price_set”: {
“shop_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “100.00”,
“currency_code”: “USD”
}
},
“product_exists”: true,
“product_id”: 6608633462884,
“properties”: ,
“quantity”: 1,
“requires_shipping”: true,
“sku”: “HAT”,
“taxable”: true,
“title”: “HAT”,
“total_discount”: “0.00”,
“total_discount_set”: {
“shop_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “0.00”,
“currency_code”: “USD”
}
},
“variant_id”: 39453535535204,
“variant_inventory_management”: “shopify”,
“variant_title”: “RED”,
“vendor”: “redliuiot”,
“tax_lines”: [
{
“channel_liable”: false,
“price”: “6.63”,
“price_set”: {
“shop_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
},
“presentment_money”: {
“amount”: “6.63”,
“currency_code”: “USD”
}
},
“rate”: 0.06625,
“title”: “New Jersey State Tax”
}
],
“duties”: ,
“discount_allocations”:
}
],
“payment_terms”: null,
“refunds”: ,
“shipping_lines”:
}
]
}
2、回传追踪号和面单

url:https://8578cc2007111d6dff8ea7b92e6fd69f:shppa1_fdda31fd9cf1f53a68675ce14ec0747f@redliuiot.myshopify.com/admin/api/2021-10/fulfillments.json
req body:

{
“fulfillment”: {
“message”: “The package was shipped this morning.”,
“notify_customer”: false,
“tracking_info”: {
“number”: 1562678,
“url”: “https://www.my-shipping-company.com”,
“company”: “my-shipping-company”
},
“line_items_by_fulfillment_order”: [{
“fulfillment_order_id”: 3897756385380,
“fulfillment_order_line_items”: [{
“id”: 10176485720164,
“quantity”: 1
}]
}]
}
}
resp body:

{
“errors”: “Not Found”
}

一如既往,还是没找到

您那边可否可以根据我的请求示例帮我调一下fulfillments接口,使他能够完成运单号和面单数据的回传