Multi location and the API

Shopify Partner
7 0 0

Starting to work with multi location in my dev store.Using XML instead of JSON because I'm used to XML and developing in VB .Net.  This is for a private app, ERP integration. Two problems of note so far :

1.) https://<storename>.myshopify.com/admin/locations.json works fine to return the list of locations.  https://<storename>.myshopify.com/admin/locations.xml does not work.  Returns an error. The API is supposed to support json and xml returns equally.

2.) There is a location-id node on the order object, but it is not populated.  It is always null.  I was expecting to see the location id of the assigned location to that order. This is critical as we need it to populate a corresponding location code in the ERP system.

 

 

 

 

0 Likes
Shopify Partner
1838 173 601

BAASS Development Admin

  1. IIRC, Shopify announced they intend to drop XML support from their APIs and have advised everyone to migrate to JSON. I know some endpoints still have XML content negotiation, but I am willing to bet newer endpoints do not. Either way, I would not be starting a new project using Shopify APIs and XML.
  2. Yeah, still haven't figured out that one entirely. I can assure you sometimes it is not null, but I would have to jot up test cases to learn exactly what loation, inventory settings and orders cause the order.location_id to be null or not.

Hope that helps!

I turn coffee in to code - since 1998
0 Likes
Shopify Partner
7 0 0

Thanks for the reply.  Oh boy ... was not aware of XML deprecation.  Re-jig time.

Haven't got too far into the multi location problem yet. Turned on multi loc yesterday and added new test orders after establishing a new location.  Assigning new or existing orders to any location does not populate that node in json or xml.  Have not tested on a new customer created since turning on multi loc. This is frustrating ... a seemingly basic notion of having the location id stamped on the order should populate that field in the API.  The web screens are fine .. they show the assigned location for each order.

0 Likes
Shopify Partner
1838 173 601

Well, I do not think the order.location_id is necessarily related to the order in terms of fulfillment location. Take for instance orders that have 2 line items. Each of those can be fulfilled by 1 fulfillment location (i.e. order line item #1 has product variant #1 which is in stock at location #1, order line item #2 has product variant #2 which is in stock at location #2). That would create a split order fulfillment. Thus, location_id is correctly tracked in order.fulfillments.location_id.

Still doesn't answer what that order.location_id does exactly and when is it null, when is it not, but I hope to find some time soon and figure it out.

I turn coffee in to code - since 1998
0 Likes
Shopify Partner
7 0 0

I agree with you.  In advance of doing any fulfillments, you can change the location of the order so it will show up in the list of orders tagged to a particular location.  It makes sense that if the order is fulfilled across multiple locations that each fulfillment (and postentially line item) would (and I think should) have their own location_id stamped.

 

0 Likes
Shopify Partner
1838 173 601

Just FYI - loads of clutter properties removed, but this is basically an order that had location_id on the order and split order fulfillments.

{
  "order": {
    "id": 902741164147,
    "location_id": 7245332595,
    "line_items": [
      {
        "id": 2046629675123,
        "variant_id": 17633409925235,
      },
      {
        "id": 2046629707891,
        "variant_id": 17633409892467,
      }
    ],
    "shipping_lines": [],
    "fulfillments": [
      {
        "id": 818363203699,
        "order_id": 902741164147,
        "location_id": 7245332595,
        "line_items": [
          {
            "id": 2046629707891,
            "variant_id": 17633409892467,
          }
        ]
      },
      {
        "id": 818358255731,
        "order_id": 902741164147,
        "location_id": 13357056115,
        "line_items": [
          {
            "id": 2046629675123,
            "variant_id": 17633409925235,
          }
        ]
      }
    ],
    "refunds": []
  }
}

 

I turn coffee in to code - since 1998
0 Likes
Shopify Partner
7 0 0

Yes! That's what I'm expecting to see.

Was the order entered via admin or storefront?  I have done all testing / order entry via admin console.

I'll keep trying ..

0 Likes
Shopify Partner
1838 173 601

Yeah, that I cannot recall :-D

UI, REST Admin API, GraphQL Admin API, Storefront API, all a big mess of in my dev store unless I have a written test - for this particular case I haven't yet so I will need to reproduce it once I start digging in to it.

Do share if you figure it out - am very curious.

I turn coffee in to code - since 1998
0 Likes
Shopify Partner
1838 173 601

So, I am creating orders with items that require split location fulfillment.

  1. Creating an order via Admin UI, order.location_id is set to shipping origin location. The order is displayed correctly regarding which item will be fulfilled by which location.
  2. Creating an order via storefront, order.location_id is null. The order is displayed correctly regarding which item will be fulfilled by which location.
  3. Creating an order via REST Admin API, order.location_id is null. The order os NOT displayed correctly since all items are set to be fulfilled by the shipping origin location even though 1 isn't in stock there.
  4. Creating an order via GraphQL Admin API (draftOrderCreate then draftOrderComplete), order.location_id is set to shipping origin location. The order is displayed correctly regarding which item will be fulfilled by which location.

From that I gather that:

  1. REST Admin API has a bug (given Admin UI also uses GraphQL Admin API and both behave same, ie correctly)
  2. When creating an order by storefront, no idea why the shipping origin location isn't set to order.location_id - possible bug?
I turn coffee in to code - since 1998
0 Likes
Highlighted
New Member
2 0 0

Hi Karl,

 

Thnx for the great explanation.

I run into the same problem with not beeing able to change fulfillment loacations for orders created by a Privata app AKA the shopify order API.

 

Did you or shopify find any solution for this over the years?

 

Kind regards Martijn

0 Likes