Error updating order without a shipping address

Santa
Excursionist
13 0 4

Hi,

 

Please let me know if there is a better discussion area to ask this question 🙂

 

I have a store where we sell a digital product so we don't collect a shipping address on the checkout page. We also have an app we use to receive and update information for the order, including adding tags and note attributes to it.

Everything was working fine until we recently started using a newer API version (2023-04). Until now we were using a version that was a few years old. Now, when we try and do something like add a note attribute to an order we get the following error:

 

Response(code=400, body="b'{"errors":{"shipping_address":"Required parameter missing or invalid"}}'"

 

In our app (written in Python) we make a session with the following code:

 

session = getShopifySession() // this returns our store URL with our API information

shopify.ShopifyResource.activate_session(session)

 

Then we create an order object with:

 

order = shopify.Order.find(ORDER_ID)

 

The error happens when we update the order with order.save()

 

This only happens when we try to update an order and not when we retrieve information about it.

 

Replies 12 (12)

tregister
Shopify Partner
3 0 0

Hello @Santa,

 

We are seeing a similar issue on our Shopify integration. Did you get the issue resolved or any response (I see none here)?

Santa
Excursionist
13 0 4

Hi @tregister,

 

I did open a support ticket and got a response there. While I never got a reason for the need to have a shipping address now, I do have a simple work around. We're just setting the shipping address to equal the billing address if it doesn't already have a shipping address. ie:

 

`if order.shipping_address == None:

     order.shipping_address = order.billing_address`

 

Maybe something like that would work for you?

tregister
Shopify Partner
3 0 0

Hi @Santa,

 

Amazingly swift reply!

Unfortunately, the billing address is usually derived from the shipping address, so no luck there.

 

Thanks for trying to help. 👍

Santa
Excursionist
13 0 4

Hi @tregister,

 

My pleasure 🙂

 

Ah, sorry to hear that. Maybe open a ticket and see if a developer can point you in the right direction?

tregister
Shopify Partner
3 0 0

Hi @Santa,

 

Will do. Thanks again.

Muttahhar
Shopify Partner
10 0 2

For anyone facing the same problem, assigning the following object as the shipping address and billing address fixes the issue.

{
  address1: nil,
  city: nil,
  company: nil,
  country: nil,
  country_code: nil,
  first_name: nil,
  last_name: nil,
  name: nil,
  phone: nil,
  province: nil,
  province_code: nil,
  zip: nil
}

 Above code is in Ruby

skillmatic
Shopify Partner
52 0 7

I'm having this issue as well. It randomly started like a week ago, nothing in my code has changed.

 

@Muttahhar 's solution did not work for me.

 

I've also opened a ticket on Github here: https://github.com/Shopify/shopify-api-ruby/issues/1270 

noaspro
New Member
5 0 0

Hi! The same issue detected using Shopify Python API.

 

 

if not order.shipping_address:
       order.shipping_address = {'address1': '', 'city': '', 'province': '', 'zip': '', 'country': ''}

.....

order.save()

 

Did the trick for now.

skillmatic
Shopify Partner
52 0 7

Not working for me. I'm still getting:

 

"{:shipping_address=>[\": Enter a last name.Select a country/region.Enter an address.Enter a postal code.Enter a city.Enter a phone number.\"]}"
noaspro
New Member
5 0 0

Interesting. Did you use single quotes to insert an "empty string" ? the bold ones?

 

order.shipping_address = {'address1': '', 'city': '', 'province': '', 'zip': '', 'country': ''}

 

 

Screenshot 2024-01-30 at 17.26.20.png

This is ShopifyAPI Python lib I use

 

Name: ShopifyAPI
Version: 12.4.0
Summary: Shopify API for Python
Home-page: https://github.com/Shopify/shopify_python_api
Author: Shopify
Author-email: developers@shopify.com
License: MIT License
Location: /usr/local/lib/python3.6/site-packages
Requires: pyactiveresource, PyJWT, PyYAML, six

 

However, I think that this is related only to API requirements, not the client library.

 

But, it's interesting that shipping_address is not listed as required in API docs (correct me if I am wrong).

 

On the other hand,  if I send "empty strings" it works, even if shipping_address should be checked by Shopify against the address model to ensure that the address is the correct real-world address.

skillmatic
Shopify Partner
52 0 7

Yeah I tried empty strings, as well as nil, with the address fields you sent as as well as others (first name, last name, phone, etc), and still getting an error. As I mentioned below, the hack of doing shopify_order.shipping_address = shopify_order.billing_address seems to have worked in the sense that it allows me to save the order, but I don't think it's an ideal solution. I think I may rely on the shipping address being nil in places in my app. Orders are allowed to not have a shipping address (digital items, etc), so why can't we save the order in the API without a shipping address?

skillmatic
Shopify Partner
52 0 7

FWIW, this hack does allow me to save the order:

 

 

shopify_order.shipping_address = shopify_order.billing_address
shopify_order.save

 

 

However this is not ideal - it's confusing to staff to have a shipping address on an order in the admin that does not require shipping. I also don't know if this effects other parts of my app where I may rely on the shipping address to be missing for orders that do not require shipping.