To create a variant with GraphQL using Shopify Flow, you can use the productVariantCreate
mutation.
Here's an example of how you can do this:
mutation {
productVariantCreate(
input: {
productId: "gid://shopify/Product/1234567890",
sku: "example-sku",
price: "19.99",
inventoryManagement: SHOPIFY,
inventoryQuantity: 10,
options: ["example-option"]
}
) {
productVariant {
id
sku
price
}
userErrors {
field
message
}
}
}
You can use this mutation in a Shopify Flow workflow by using the Send HTTP request
action and setting the request method to POST
, the URL to https://your-store.shopify.com/api/2022-04/graphql.json
, and the request body to the above GraphQL mutation.
You can also use the Create product variant
action in Shopify Flow, which allows you to create a new variant without writing GraphQL code.
For more information, you can refer to the Shopify GraphQL API documentation and the Shopify Flow documentation.
You can also check the ProductVariant Graphql API object for more details on the available fields and mutations.
Note that you need to replace "gid://shopify/Product/1234567890"
with the actual ID of the product you want to create the variant for, and "example-sku"
, "19.99"
, 10
, and "example-option"
with the actual values you want to use for the variant.
Also, make sure to check the triggers.json document for more information on the available triggers and actions in Shopify Flow.
You can also check the actions.json document for more information on the available actions and their fields.
You can also check the templates.json document for more information on the available templates and their descriptions.
Please let me know if you need more information or help with implementing this in your Shopify Flow workflow.