
This has been a common issue that many of you have encountered lately. And it is entirely understandable, as updating product options in product variants as options fields in GraphQL and Rest API are altogether different.
However, you can follow the standard procedure;
Step 1 – Login to your Shopify Admin panel
Step 2 – Go to the products
Step 3: Click on the product’s name with the variant name you would like to change.
Step 4 – Make appropriate changes in the variant details
Step 5 – Click to Save
Or else, you can follow this method where;
We are updating product variants using GraphQL. Here, our primary goal is to send three different options (large, blue, and paper) to the product variant to convert it into one single variant with only one [String!] value. Also, in REST APIs, it consists of three different options (Option1, Option2, and Option3) with unchanged default titles.
You can consider the below links:
Update Product Variant: https://shopify.dev/docs/api/admin-graphql/2024-07/mutations/productvariantupdate
Update Product: https://shopify.dev/docs/api/admin-graphql/2024-10/mutations/productupdate
Well, it actually takes an array of strings ([String!]), not a single string value. So you need to pass it like that [“Large”, “Blue”, “Paper”], see detailed mutation request below:
Query
mutation productVariantUpdate($input: ProductVariantInput!) { productVariantUpdate(input: $input) {
product {
id
title
handle
}
productVariant {
id,
selectedOptions {
name,
value
}
}
userErrors {
field
message
}
}
}
Variables
{ "input": { "id": "gid://shopify/ProductVariant/12386472609940", "options": ["Small", "Medium", "Large"] } }
AboutManthan Bhavsar
Related Posts
What is The Importance of On-Demand Taxi Booking Apps & How Much Does it Cost to Develop?
The development of the cab booking industry is rapidly growing, and its service has become essential across many countries....
Testing Push Notification On iOS Simulator – Developer Guide!
Push notifications are the only way through which users can stay updated about your Application. In iOS applications, The...