New Shopify Certification now available: Liquid Storefronts for Theme Developers

Update Variant price for an inventory

APihelper
Visitor
2 0 0

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 
GearIT _ Products _ GearIT (10-Pack) Cat6 RJ45 Keystone Jack, Punch Down _ Shopify(1).jpg

 

Thanks  

 

 

Replies 3 (3)
tewe
Shopify Partner
241 46 102

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

 

 

 

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App
APihelper
Visitor
2 0 0

Hi thank you for your answer is there any way that I can try with postman api

tewe
Shopify Partner
241 46 102

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

 

• Was my reply helpful? Click Like to let me know!
• Was your question answered? Mark it as an Accepted Solution
• Check out our Price Updater App