Dedicated to the Hydrogen framework, headless commerce, and building custom storefronts using the Storefront API.
Hi Team
I'm trying to update just a variant price inside an inventory using API I don't know the requirement
if you look to the image I need to update one variant price based on
SKU
Shopify Item id
Thanks
Hi @APihelper ,
to achieve this there are two steps required:
1. Identify the variant with the given SKU. A GraphQL query for the SKU=123 might look like
{
productVariants(first:10, query: "sku:'123'") {
edges {
node {
id
sku
}
}
}
}
This will return the id of the relevant product variant. The id will look somehow like gid://shopify/ProductVariant/39316904411301
2. Update the price of the variant as usual:
mutation productVariantUpdate($input: ProductVariantInput!) {
productVariantUpdate(input: $input) {
product {
title
}
productVariant {
id
price
}
userErrors {
message
}
}
}
with the variables
{"input": {"id":"gid://shopify/ProductVariant/39316904411301", "price": 999.00}}
Hi thank you for your answer is there any way that I can try with postman api
Hi @APihelper ,
sure you can use it with Postman. The queries above are just the bodies. For details, see https://www.postman.com/lively-moon-541169/workspace/purego-apis/collection/16545848-a4955a94-adac-4...
Regards
Thomas