通过API创建Shopify订单时,如何包括送货地址和帐单地址?

时间:2019-03-08 19:46:03

标签: shopify

我在Shopify论坛上发布了一个问题,但认为它将在这里引起更多关注:https://community.shopify.com/c/Shopify-APIs-SDKs/POSTing-to-orders-json-not-saving-billing-address-or-shipping/m-p/488324

我们有一个第三方系统,可以通过Shopify API在Shopify中创建订单。我们能够成功创建订单,但是即使根据API提供了送货地址和帐单地址也永远不会显示在订单上。

这是我们要发送的有效载荷:

{  
  billing_address:{  
     address1:'123 Main Street',
     address2:'',
     city:'London',
     province:'Ontario',
     country:'Canada',
     zip:'N6G 4B2',
     province_code:'ON',
     country_code:'CA',
     country_name:'Canada',
     phone:'555-555-5555'
  },
  customer:{
     first_name:'John',
     last_name:'Doe',
     email:'john@doe.ca',
     addresses:[
        [  
           {
            address1:'123 Main Street',
            address2:'',
            city:'London',
            province:'Ontario',
            country:'Canada',
            zip:'N6G 4B2',
            province_code:'ON',
            country_code:'CA',
            country_name:'Canada',
            phone:'555-555-5555'
           }
        ]
     ]
  },
  fulfillment_status:null,
  inventory_behaviour:'decrement_ignoring_policy',
  financial_status:'paid',
  line_items:[  
     {  
        variant_id: 94902079324,
        quantity: 1,
        price: '0.00'
     }
  ],
  shipping_address:{  
    address1:'123 Main Street',
    address2:'',
    city:'London',
    province:'Ontario',
    country:'Canada',
    zip:'N6G 4B2',
    province_code:'ON',
    country_code:'CA',
    country_name:'Canada',
    phone:'555-555-5555'
  }
}

示例中提供的地址不是有效地址,但是我们的实际数据中包含有效地址。

这是我们在管理员中看到的:

enter image description here

1 个答案:

答案 0 :(得分:1)

这对shipping_address有用,但是无法创建billing_address。您可以尝试以下方法:

{
   "Order" : {
     #all other attributes,

    "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"
     }
   }
}

花了很多时间之后,我发现City出现在这里需要shipping_address。尝试调整city属性并检查。