Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more
mutation productVariantsBulkCreate($productId: ID!, $media: [CreateMediaInput!] , $strategy:ProductVariantsBulkCreateStrategy!, $variants: [ProductVariantsBulkInput!]!) { productVariantsBulkCreate(productId: $productId, variants: $variants, media: $media, strategy:$strategy) { product { id } userErrors { field message } } }
I used the productVariantsBulkCreate mutation to create new variant, with full of params for payload:
{
"productId": "gid://shopify/Product/9562088571168",
"media": [
{
"alt": "https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg",
"mediaContentType": "IMAGE",
"originalSource": "https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg"
}
],
"variants": [
{
"compareAtPrice": "77662.99",
"price": "51775.45",
"inventoryItem": {
"cost": "25887.60",
"tracked": true
},
"inventoryPolicy": "CONTINUE",
"inventoryQuantities": {
"availableQuantity": 2399,
"locationId": "gid://shopify/Location/100882448672"
},
"mediaSrc": [
"https://ae01.alicdn.com/kf/H24419e74b70343adace6eeac02046e040.jpg"
],
"optionValues": [
{
"name": "Size",
"optionName": "8 inch"
},
{
"name": "Color",
"optionName": "honeycomb Tan"
}
],
"taxable": true
}
]
}
I've checked some questions related with this mutation, and make sure that my payload is correct. But when running, I got the error:
"errors": [ { "message": "Option does not exist", "locations": [ { "line": 2, "column": 3 } ], "path": [ "productVariantsBulkCreate" ] } ]
What are the errors? How can I fix to create new variant success?
Sorry all,
I found my error:
name => name of variant selected option ( like L,M, Blue, White...)
optionName. => name of product option (like Size, Color, Material)
But I did with the reverse back. My problem was fixed.
Thanks all,