POSTing to orders.json not saving billing_address or shipping_address

GregSmithRR
Tourist
12 0 2

We're importing orders from a 3rd party system for inventory management in Shopify as our customer uses their Shopify store to sell products online but they also sell products though the 3rd party.

 

I'm POSTing to orders.json API and the order is being created correctly, except the billing_address and shipping_address aren't being saved.

 

Here's the payload that I'm sending:

 

 
{  
  billing_address:{  
     address1:'123 Main Street',
     address2:'',
     city:'London',
     province:'Ontario',
     country:'Canada',
     zip:'N6G 42B',
     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 42B',
            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 42B',
    province_code:'ON',
    country_code:'CA',
    country_name:'Canada',
    phone:'555-555-5555'
  }
}

I saw this in the documentation and was a bit confused about what it means:

 

billing_address: The mailing address associated with the payment method. This address is an optional field that won't be available on orders that do not require a payment method.

 

shipping_address: 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.

 

Is there something in the payload that would make it so I can't set those values? If billing_address can't be set because I'm marking the address paid I kinda get that but it didn't work when I set it to pending either.

 

 

Thanks,

Greg

 
0 Likes
GregSmithRR
Tourist
12 0 2

I realize my above payload has an invalid postal code, but I confirmed with a correct, valid address the problem persists.

0 Likes
GregSmithRR
Tourist
12 0 2

Bumping this and also clarifying some things...

 

Here is a copy of the payload I'm sending via POSTMAN

 

{
  "order": {
    "billing_address": {
      "address1": "123 Main Street",
      "address2": "",
      "city": "London",
      "province": "Ontario",
      "country": "Canada",
      "zip": "N6A 3A3",
      "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": "N6A 3A3",
	        "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": 18564945379385,
        "quantity": 1,
        "price": "0.00"
      }
    ],
    "shipping_address": {
      "address1": "123 Main Street",
      "address2": "",
      "city": "London",
      "province": "Ontario",
      "country": "Canada",
      "zip": "N6A 3A3",
      "province_code": "ON",
      "country_code": "CA",
      "country_name": "Canada",
      "phone": "555-555-5555"
    }
  }
}

 

The order gets created in Shopify, but the `SHIPPING ADDRESS` and `BILLING ADDRESS` on the Order admin page show `No shipping address`. The customer is new and the `DEFAULT ADDRESS` on the customer admin is set.

 

Screen Shot 2019-07-03 at 09.56.28.png

 

Orders created through the web store have these addresses on the Order admin page, but the ones we create through the API never do.

 

Is there something in the store settings that would be causing this?

0 Likes
GregSmithRR
Tourist
12 0 2

OMG FINALLY someone came to the rescue on StackOverflow. The reason the shipping information wasn't showing up on the Order admin page is because I wasn't providing `first_name` and `last_name` in the `shipping_address` property. And be warned, you need BOTH `first_name` and `last_name`!

 

THIS works:

{

  "order": {
    ...,
    "shipping_address": {
      "first_name": "John",
      "last_name": "Doe",
      "address1": "103 King Street",
      "address2": "",
      "city": "London",
      "province": "Ontario",
      "country": "Canada",
      "zip": "N6A 6K1",
      "province_code": "ON",
      "country_code": "CA",
      "country_name": "Canada",
      "phone": "555-555-5555"
  }
}

Frustrated that the Order API docs don't make mention of this anywhere. I submitted feedback on the docs, but hoping that some moderator here will also see this and update the docs.

ravimobifyi
New Member
4 0 0

Hi, 
I am also having some troubles in getting Billing Address
I am providing both first_name and last_name in shipping and billing address but i could see shipping address only
there is no billing address displayed in order page
is thiss because i did not add transaction object in order request ?

did you able to get billing address ?

0 Likes