Our Partner & Developer boards on the community are moving to a brand new home: the .dev community forums! While you can still access past discussions here, for all your future app and storefront building questions, head over to the new forums.

Re: location ID question

Solved

location ID question

weap0n7
Shopify Partner
25 1 2

I'm trying to create a productVariant.
I want to put in the inventory quantity, but it says to enter inventoryQuantities.locationId as required. I want to know how to know locationId.

 

mutation productVariantCreate($input: ProductVariantInput!) {
  productVariantCreate(input: $input) {
    product {
      id
      title
    }
    productVariant {
      createdAt
      displayName
      id
      inventoryItem {
        unitCost {
          amount
        }
        tracked
      }
      inventoryPolicy
      inventoryQuantity
      price
      product {
        id
      }
      title
    }
    userErrors {
      field
      message
    }
  }
}


{
  "input": {
    "inventoryItem": {
      "cost": 50,
      "tracked": false
    },
    "inventoryPolicy": "DENY",
    "inventoryQuantities": {
      "availableQuantity": 25,
      "locationId": "???"
    },
    "price": 114.99,
    "productId": "gid://shopify/Product/8730477592876",
    "requiresShipping": true,
    "options": "Holographic"
  }
}
Accepted Solutions (2)

weap0n7
Shopify Partner
25 1 2

This is an accepted solution.

It worked itself out.
Location lookup endpoint found.
 
{
  location {
    id
  }
}

View solution in original post

SBD_
Shopify Staff
1831 273 423

This is an accepted solution.

Hey @weap0n7 

 

These are available via the locations query.

Scott | Developer Advocate @ Shopify 

View solution in original post

Replies 5 (5)

weap0n7
Shopify Partner
25 1 2

This is an accepted solution.

It worked itself out.
Location lookup endpoint found.
 
{
  location {
    id
  }
}

SBD_
Shopify Staff
1831 273 423

This is an accepted solution.

Hey @weap0n7 

 

These are available via the locations query.

Scott | Developer Advocate @ Shopify 

densekernel
Shopify Partner
9 0 0

I was able to get a single location returned from the locations query:

 

```

{
"id": "gid://shopify/Location/XXXXXXX",
"name": "Shop location",
"shipsInventory": true,
"fulfillmentService": null,
"deletable": false,
"suggestedAddresses": [],
"__typename": "Location"
}

```

 

Presumably this location is automatically created for all online stores and this will be the default.

 

How do we distinguish between other locations that the merchant might have created?

SIG_KAP
Shopify Partner
8 0 5

where you able to actually update the inventory quanity at a location using the productVariantCreate mutation. I just tried and it's not working for me

 

mutation productVariantUpdate($input: ProductVariantInput!) {
  productVariantUpdate(input: $input) {
    product {
      id
    }
    productVariant {
      id
      inventoryQuantity
    }
    userErrors {
      field
      message
    }
  }
}

 

varibles

{
  "input": {
    "id": "gid://shopify/ProductVariant/43301196234XXX",
    
    "inventoryQuantities": [
      {
        "availableQuantity": 5,
        "locationId": "gid://shopify/Location/69836603XXX"
      }
    ]
  }
}

Result

{
  "data": {
    "productVariantUpdate": {
      "product": {
        "id": "gid://shopify/Product/7751192510XXX"
      },
      "productVariant": {
        "id": "gid://shopify/ProductVariant/43301196234XXX",
        "inventoryQuantity": 38
      },
      "userErrors": []
    }
  },
  "extensions": {
    "cost": {
      "requestedQueryCost": 10,
      "actualQueryCost": 10,
      "throttleStatus": {
        "maximumAvailable": 2000,
        "currentlyAvailable": 1990,
        "restoreRate": 100
      }
    }
  }
}


Nothign updated.  

kyo00710
Shopify Partner
16 0 7

The inventory locations, I think this is where saving stock of products.

When you create store, it has a default location for store, is the main location.

You can create more location with fulfillmentService mutation, this called the location of custom app.

 

However, you can only set the quantity of products when creating product, using productVariantBulkCreate mutation.

 

When updating product with inventory parameters, it do nothing.

For updating, you can use the inventoryAdjustQuantities mutation instead.