updating note attributes requires valid shipping address

Solved
Tourist
11 0 0

I have created an order via Admin panel - and by doing it this way you are not required to give a full shipping address. For instance, you can have a blank address1, phone, or city (these fields are required if the order is placed by the customer).

 

Trying to update the note attributes of this order via the ShopifyAPI returns an error -

shipping_address: ["address1 can't be blank and city can't be blank"] 

Just for a bit of background, this is how I'm updating the order (using a rails environment)

shopify_order = ShopifyAPI::Order.find(5437347592)
shopify_attributes = {"Requested Delivery Date"=>"", "Shipping Date"=>"2017/10/16", "Timeslot"=>"", "Special Instructions"=>""}
shopify_order.update_attributes(note_attributes: shopify_attributes)

I find this strange - like it could be a bug. Why would a valid shipping address be required to update note attributes?

 

0 Likes
Highlighted

Success.

Shopify Staff
Shopify Staff
1127 79 162

Hey @seshna , 

 

It's actually the shopify_api gem that causes this. When it updates an order, it sends every single field when trying to perform the update. So while you may not realize it, you actually are updating the order address while updating note attributes (as well as every other field on the order). Because it then sends an incomplete address to the Order API while doing this, the order address validation kicks in and throws an error instead of letting the update complete. 

 

If you were to perform the same API call with an HTTP client or even just a cURL request, your update would work fine. 

0 Likes
Highlighted
Tourist
11 0 0

Thank you Josh,

I understand - I appreciate you taking the time.

0 Likes