SomethingOn
SomethingOn

Reputation: 10911

How do I include the shipping and billing address when creating a Shopify order through the API?

I posted a question on the Shopify forums, but figured it would hit more eyeballs here: https://community.shopify.com/c/Shopify-APIs-SDKs/POSTing-to-orders-json-not-saving-billing-address-or-shipping/m-p/488324

We have a 3rd party system that creates orders in Shopify through the Shopify API. We're able to successfully create the order, but the Shipping address and Billing address never show up on the order even though they're supplied according to the API.

This is the payload we're sending:

{  
  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:'[email protected]',
     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'
  }
}

The address supplied in the example is not a valid address, but our actual data has valid addresses.

This is what we see in the admin:

enter image description here

Upvotes: 1

Views: 3376

Answers (1)

Talha Junaid
Talha Junaid

Reputation: 944

This worked for me for shipping_address but wasn't able to create the billing_address. You can try this:

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

After spending alot of time I found out that City is required for shipping_address to show up there. Try tweaking the city attribute and check.

Upvotes: 3

Related Questions