location ID question

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"
  }
}

It worked itself out.
Location lookup endpoint found.

{
location {
id
}
}

Hey @weap0n7

These are available via the locations query.

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.

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?

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.