Cannot destroy inventory level / Can't fulfill orders with single fulfillment

Highlighted
Shopify Partner
23 0 2

We have a merchant that has several multi-unit orders that we are trying to fulfill. We are trying to fulfill each order with a single fulfillment - the merchant STRONGLY prefers to see only one fulfillment notification. We are shipping each of these orders with one shipment, so creating a single fulfillment is what is called for. 

 

We are using the Shopify Python API

 

All of the variants have inventory levels that are assigned to our location, except one. 

 

SKU X: Location Ours, A

SKU Y: Location Somewhere else, B

 

We can't create a single fulfillment for this order, because we get the error "All line items must be stocked at the same location."

 

No problem. So let's move SKU Y to our location, Location A. 

 

But this is impossible. 

 

SKU Y, has an inventory item, which has a single inventory level at Location B. 

 

But this is impossible.

 

It's not possible to:

  1. Delete the inventory level at Location B, create a new one at Location A
  2. Zero out the inventory level at B and create a new inventory level at Location A
  3. Delete the inventory item all together

So what can we do? 

 

Option 1 - Delete the inventory level at Location B

 

shopify_variant = shopify.Variant.find(Y ID)
inventory_levels = shopify.InventoryLevel.find(inventory_item_ids=shopify_variant.inventory_item_id)
level_b = inventory_levels[0]
level_b.destroy()

 

'X-Request-ID': 'b5079cd1-dc70-4ce2-8cef-c97806299563'

 

It seems someone has thought of this and actually created InventoryLevel.destroy in the SDK. 

 

But this gives the error:

 

urllib.error.HTTPError: HTTP Error 422: Unprocessable Entity

 

It looks like the SDK has thought of this, and the API documentation specifically mentions that DELETE should work, but it does not. 

 

Option 2 - Zero out the level at B and create a new inventory Level at A

 

shopify_variant = shopify.Variant.find(Y ID)
inventory_levels = shopify.InventoryLevel.find(inventory_item_ids=shopify_variant.inventory_item_id)
level_b = inventory_levels[0]
shopify.InventoryLevel.set(level_b.location_id, shopify_variant.inventory_item_id, 0)
shopify.InventoryLevel.set(our_location_id, shopify_variant.inventory_item_id, 1000)

'X-Request-ID': 'cce3d946-10b5-427e-9ce2-befd4ad5c270'

 

The last line doesn't work either. We get an error:

 

urllib.error.HTTPError: HTTP Error 422: Unprocessable Entity

An item cannot be active at more than one location if one of them is a fulfillment service location.

 

Um, sorry? Is it really active if the inventory is 0 at the other location? We can't delete the other location.. so what do we do?

 

Option 3 - Delete the inventory item all together

 

Let's try to delete the inventory item all together and start over?

 

shopify_variant = shopify.Variant.find(Y ID)
item = shopify.InventoryItem.find(shopify_variant.inventory_item_id)
item.destroy() 
item.delete()

Neither item.delete or destroy work here, the InventoryItem class doesn't have a destroy method. It was a long shot - but I thought I'd mention I tried this to show that I've looked at the problem thoroughly. 

 

So what do we do here? Our merchant is less than satisfied that we are essentially creating duplicate fulfillments for the same order. We have to create one fulfillment for SKU X and one for SKU Y with the same tracking information in order to mark the order as fulfilled. 

 

 

0 Likes
Highlighted
Shopify Partner
23 0 2

It looks like this is the answer:

 

shopify.InventoryLevel.connect(
our_location_id,
shopify_variant.inventory_item_id,
relocate_if_necessary=True
)
0 Likes