Requires write_products
access scope. Also: The user must have a permission to update product variants.
Reorders the options and option values on a product, updating the order in which product variants are presented to customers.
The productOptionsReorder
mutation accepts a list of product options, each identified by id
or name
, and an optional list of values (also by id
or name
) specifying the new order. The order of options in the mutation's input determines their new positions (for example, the first option becomes option1
). The order of values within each option determines their new positions. The mutation recalculates the order of variants based on the new option and value order.
Suppose a product has the following variants:
"Red / Small"
"Green / Medium"
"Blue / Small"
You reorder options and values:
options: [
{ name: "Size", values: [{ name: "Small" }, { name: "Medium" }] },
{ name: "Color", values: [{ name: "Green" }, { name: "Red" }, { name: "Blue" }] }
]
The resulting variant order will be:
"Small / Green"
"Small / Red"
"Small / Blue"
"Medium / Green"
Use the productOptionsReorder
mutation for the following use cases:
The productOptionsReorder
mutation enforces strict data integrity for product options and variants. All option positions must be sequential, and every option should be used by at least one variant.
After you reorder product options, you can further manage a product's configuration using related mutations:
productOptionsCreate
productOptionsDelete
productVariantsBulkCreate
productVariantsBulkUpdate
productSet
Learn more about the product model and managing product data.
Options to reorder on the product.
The ID of the product to update.
The updated product object.
The list of errors that occurred from executing the mutation.
mutation reorderOptions($options: [OptionReorderInput!]!, $productId: ID!) { productOptionsReorder(options: $options, productId: $productId) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }
curl -X POST \ https://your-development-store.myshopify.com/admin/api/2025-07/graphql.json \ -H 'Content-Type: application/json' \ -H 'X-Shopify-Access-Token: {access_token}' \ -d '{ "query": "mutation reorderOptions($options: [OptionReorderInput!]!, $productId: ID!) { productOptionsReorder(options: $options, productId: $productId) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }", "variables": { "productId": "gid://shopify/Product/1072481177", "options": [ { "name": "Color", "values": [ { "name": "Green" }, { "name": "Blue" }, { "name": "Red" } ] }, { "name": "Size" } ] } }'
const { admin } = await authenticate.admin(request); const response = await admin.graphql( `#graphql mutation reorderOptions($options: [OptionReorderInput!]!, $productId: ID!) { productOptionsReorder(options: $options, productId: $productId) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }`, { variables: { "productId": "gid://shopify/Product/1072481177", "options": [ { "name": "Color", "values": [ { "name": "Green" }, { "name": "Blue" }, { "name": "Red" } ] }, { "name": "Size" } ] }, }, ); const data = await response.json();
const client = new shopify.clients.Graphql({session}); const data = await client.query({ data: { "query": `mutation reorderOptions($options: [OptionReorderInput!]!, $productId: ID!) { productOptionsReorder(options: $options, productId: $productId) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } }`, "variables": { "productId": "gid://shopify/Product/1072481177", "options": [ { "name": "Color", "values": [ { "name": "Green" }, { "name": "Blue" }, { "name": "Red" } ] }, { "name": "Size" } ] }, }, });
session = ShopifyAPI::Auth::Session.new( shop: "your-development-store.myshopify.com", access_token: access_token ) client = ShopifyAPI::Clients::Graphql::Admin.new( session: session ) query = <<~QUERY mutation reorderOptions($options: [OptionReorderInput!]!, $productId: ID!) { productOptionsReorder(options: $options, productId: $productId) { userErrors { field message code } product { id options { id name values position optionValues { id name hasVariants } } variants(first: 5) { nodes { id title selectedOptions { name value } } } } } } QUERY variables = { "productId": "gid://shopify/Product/1072481177", "options": [ { "name": "Color", "values": [ { "name": "Green" }, { "name": "Blue" }, { "name": "Red" } ] }, { "name": "Size" } ] } response = client.query(query: query, variables: variables)
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4