Version: 2024-10
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) { quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) { userErrors { field code message } quantityRules { minimum maximum increment isDefault originType productVariant { id } } } }\",\n \"variables\": {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": null,\n \"increment\": 1\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 5,\n \"maximum\": 25,\n \"increment\": 5\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": null,\n \"increment\": 1\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 5,\n \"maximum\": 25,\n \"increment\": 5\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [{\"variantId\"=>\"gid://shopify/ProductVariant/138327650\", \"minimum\"=>1, \"maximum\"=>nil, \"increment\"=>1}, {\"variantId\"=>\"gid://shopify/ProductVariant/113711323\", \"minimum\"=>5, \"maximum\"=>25, \"increment\"=>5}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"priceListId\" => \"gid://shopify/PriceList/155157792\",\n \"quantityRules\" => [{\"variantId\"=>\"gid://shopify/ProductVariant/138327650\", \"minimum\"=>1, \"maximum\"=>nil, \"increment\"=>1}, {\"variantId\"=>\"gid://shopify/ProductVariant/113711323\", \"minimum\"=>5, \"maximum\"=>25, \"increment\"=>5}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": null,\n \"increment\": 1\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 5,\n \"maximum\": 25,\n \"increment\": 5\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n}"
input: { "priceListId": "gid://shopify/PriceList/155157792", "quantityRules": [ { "variantId": "gid://shopify/ProductVariant/138327650", "minimum": 1, "maximum": null, "increment": 1 }, { "variantId": "gid://shopify/ProductVariant/113711323", "minimum": 5, "maximum": 25, "increment": 5 } ] }
response: { "data": { "quantityRulesAdd": { "userErrors": [], "quantityRules": [ { "minimum": 1, "maximum": null, "increment": 1, "isDefault": true, "originType": "FIXED", "productVariant": { "id": "gid://shopify/ProductVariant/138327650" } }, { "minimum": 5, "maximum": 25, "increment": 5, "isDefault": false, "originType": "FIXED", "productVariant": { "id": "gid://shopify/ProductVariant/113711323" } } ] } } }
Curl example: "curl -X POST \\\nhttps://your-development-store.myshopify.com/admin/api/2024-10/graphql.json \\\n-H 'Content-Type: application/json' \\\n-H 'X-Shopify-Access-Token: {access_token}' \\\n-d '{\n\"query\": \"mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) { quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) { userErrors { field code message } quantityRules { minimum maximum increment isDefault originType productVariant { id } } } }\",\n \"variables\": {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": 5,\n \"increment\": 2\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 10,\n \"maximum\": 5,\n \"increment\": 5\n }\n ]\n }\n}'\n" Node example: "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }`,\n \"variables\": {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": 5,\n \"increment\": 2\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 10,\n \"maximum\": 5,\n \"increment\": 5\n }\n ]\n },\n },\n});\n" Ruby example: "session = ShopifyAPI::Auth::Session.new(\n shop: \"your-development-store.myshopify.com\",\n access_token: access_token\n)\nclient = ShopifyAPI::Clients::Graphql::Admin.new(\n session: session\n)\n\nquery = <<~QUERY\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }\nQUERY\n\nvariables = {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [{\"variantId\"=>\"gid://shopify/ProductVariant/138327650\", \"minimum\"=>1, \"maximum\"=>5, \"increment\"=>2}, {\"variantId\"=>\"gid://shopify/ProductVariant/113711323\", \"minimum\"=>10, \"maximum\"=>5, \"increment\"=>5}]\n}\n\nresponse = client.query(query: query, variables: variables)\n" PHP example: "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }\nQUERY;\n\n$variables = [\n \"priceListId\" => \"gid://shopify/PriceList/155157792\",\n \"quantityRules\" => [{\"variantId\"=>\"gid://shopify/ProductVariant/138327650\", \"minimum\"=>1, \"maximum\"=>5, \"increment\"=>2}, {\"variantId\"=>\"gid://shopify/ProductVariant/113711323\", \"minimum\"=>10, \"maximum\"=>5, \"increment\"=>5}],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" Remix example: "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n }`,\n {\n variables: {\n \"priceListId\": \"gid://shopify/PriceList/155157792\",\n \"quantityRules\": [\n {\n \"variantId\": \"gid://shopify/ProductVariant/138327650\",\n \"minimum\": 1,\n \"maximum\": 5,\n \"increment\": 2\n },\n {\n \"variantId\": \"gid://shopify/ProductVariant/113711323\",\n \"minimum\": 10,\n \"maximum\": 5,\n \"increment\": 5\n }\n ]\n },\n },\n);\n\nconst data = await response.json();\n" Graphql query: "mutation quantityRulesAdd($priceListId: ID!, $quantityRules: [QuantityRuleInput!]!) {\n quantityRulesAdd(priceListId: $priceListId, quantityRules: $quantityRules) {\n userErrors {\n field\n code\n message\n }\n quantityRules {\n minimum\n maximum\n increment\n isDefault\n originType\n productVariant {\n id\n }\n }\n }\n}"
input: { "priceListId": "gid://shopify/PriceList/155157792", "quantityRules": [ { "variantId": "gid://shopify/ProductVariant/138327650", "minimum": 1, "maximum": 5, "increment": 2 }, { "variantId": "gid://shopify/ProductVariant/113711323", "minimum": 10, "maximum": 5, "increment": 5 } ] }
response: { "data": { "quantityRulesAdd": { "userErrors": [ { "field": [ "quantityRules", "0", "increment" ], "code": "INCREMENT_IS_GREATER_THAN_MINIMUM", "message": "Increment must be lower than or equal to the minimum." }, { "field": [ "quantityRules", "0", "maximum" ], "code": "MAXIMUM_NOT_MULTIPLE_OF_INCREMENT", "message": "Maximum must be a multiple of the increment." }, { "field": [ "quantityRules", "0", "minimum" ], "code": "MINIMUM_NOT_MULTIPLE_OF_INCREMENT", "message": "Minimum must be a multiple of the increment." }, { "field": [ "quantityRules", "1", "minimum" ], "code": "MINIMUM_IS_GREATER_THAN_MAXIMUM", "message": "Minimum must be lower than or equal to the maximum." } ], "quantityRules": [] } } }