discount Code Basic Updatemutation
mutation
2024-10latest
Requires Apps must have write
access scope.
Updates a basic code discount.
Arguments
The input data used to update the code discount.
The ID of the code discount to update.
Was this section helpful?
DiscountCodeBasicUpdatePayload returns
The updated code discount.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: discountCodeBasicUpdate
Query Reference for MUTATION: discountCodeBasicUpdate
"mutation discountCodeBasicUpdate($basicCodeDiscount: DiscountCodeBasicInput!, $id: ID!) {\n discountCodeBasicUpdate(basicCodeDiscount: $basicCodeDiscount, id: $id) {\n codeDiscountNode {\n # DiscountCodeNode fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountCodeBasicUpdate
"{\n \"basicCodeDiscount\": {\n \"appliesOncePerCustomer\": true,\n \"code\": \"<your-code>\",\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true,\n \"shippingDiscounts\": true\n },\n \"customerGets\": {\n \"appliesOnOneTimePurchase\": true,\n \"appliesOnSubscription\": true,\n \"items\": {\n \"all\": true,\n \"collections\": {\n \"add\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"remove\": [\n \"gid://shopify/<objectName>/10079785100\"\n ]\n },\n \"products\": {\n \"productVariantsToAdd\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"productVariantsToRemove\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"productsToAdd\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"productsToRemove\": [\n \"gid://shopify/<objectName>/10079785100\"\n ]\n }\n },\n \"value\": {\n \"discountAmount\": {\n \"amount\": \"29.99\",\n \"appliesOnEachItem\": true\n },\n \"discountOnQuantity\": {\n \"effect\": {\n \"amount\": \"29.99\",\n \"percentage\": 1.1\n },\n \"quantity\": \"50\"\n },\n \"percentage\": 1.1\n }\n },\n \"customerSelection\": {\n \"all\": true,\n \"customerSegments\": {\n \"add\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"remove\": [\n \"gid://shopify/<objectName>/10079785100\"\n ]\n },\n \"customers\": {\n \"add\": [\n \"gid://shopify/<objectName>/10079785100\"\n ],\n \"remove\": [\n \"gid://shopify/<objectName>/10079785100\"\n ]\n }\n },\n \"endsAt\": \"2019-09-07T15:50:00Z\",\n \"minimumRequirement\": {\n \"quantity\": {\n \"greaterThanOrEqualToQuantity\": \"50\"\n },\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"29.99\"\n }\n },\n \"recurringCycleLimit\": 1,\n \"startsAt\": \"2019-09-07T15:50:00Z\",\n \"title\": \"<your-title>\",\n \"usageLimit\": 1\n },\n \"id\": \"gid://shopify/<objectName>/10079785100\"\n}"
Schema Reference for MUTATION: discountCodeBasicUpdate
"input DiscountCodeBasicInput {\n appliesOncePerCustomer: Boolean\n code: String\n combinesWith: DiscountCombinesWithInput\n customerGets: DiscountCustomerGetsInput\n customerSelection: DiscountCustomerSelectionInput\n endsAt: DateTime\n minimumRequirement: DiscountMinimumRequirementInput\n recurringCycleLimit: Int\n startsAt: DateTime\n title: String\n usageLimit: Int\n}\n\ninput DiscountCombinesWithInput {\n orderDiscounts: Boolean\n productDiscounts: Boolean\n shippingDiscounts: Boolean\n}\n\ninput DiscountCustomerGetsInput {\n appliesOnOneTimePurchase: Boolean\n appliesOnSubscription: Boolean\n items: DiscountItemsInput\n value: DiscountCustomerGetsValueInput\n}\n\ninput DiscountCustomerSelectionInput {\n all: Boolean\n customerSegments: DiscountCustomerSegmentsInput\n customers: DiscountCustomersInput\n}\n\ninput DiscountMinimumRequirementInput {\n quantity: DiscountMinimumQuantityInput\n subtotal: DiscountMinimumSubtotalInput\n}\n"
Display Examples for MUTATION: discountCodeBasicUpdate
[ { "example": { "type_name": "discountcodebasicupdate", "title": "Update a basic code discount", "description": "Modify the percentage discount of a code discount to 40%, and make it never expire.", "query_string": "mutation discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {\n discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n startsAt\n endsAt\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n customerGets {\n value {\n ... on DiscountPercentage {\n percentage\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n appliesOncePerCustomer\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}", "variables": { "id": "gid://shopify/DiscountCodeNode/206265824", "basicCodeDiscount": { "endsAt": null, "customerGets": { "value": { "percentage": 0.4 } } } }, "response": { "data": { "discountCodeBasicUpdate": { "codeDiscountNode": { "codeDiscount": { "title": "percentage_off_code", "codes": { "nodes": [ { "code": "percentage_off_code" } ] }, "startsAt": "2024-09-03T01:05:24Z", "endsAt": null, "customerSelection": { "allCustomers": true }, "customerGets": { "value": { "percentage": 0.4 }, "items": { "allItems": true } }, "appliesOncePerCustomer": false } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_code_basic_update_test.rb", "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 discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) { discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) { codeDiscountNode { codeDiscount { ... on DiscountCodeBasic { title codes(first: 10) { nodes { code } } startsAt endsAt customerSelection { ... on DiscountCustomerAll { allCustomers } } customerGets { value { ... on DiscountPercentage { percentage } } items { ... on AllDiscountItems { allItems } } } appliesOncePerCustomer } } } userErrors { field code message } } }\",\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\",\n \"basicCodeDiscount\": {\n \"endsAt\": null,\n \"customerGets\": {\n \"value\": {\n \"percentage\": 0.4\n }\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {\n discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n startsAt\n endsAt\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n customerGets {\n value {\n ... on DiscountPercentage {\n percentage\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n appliesOncePerCustomer\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\",\n \"basicCodeDiscount\": {\n \"endsAt\": null,\n \"customerGets\": {\n \"value\": {\n \"percentage\": 0.4\n }\n }\n }\n },\n },\n);\n\nconst data = await response.json();\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 discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {\n discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n startsAt\n endsAt\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n customerGets {\n value {\n ... on DiscountPercentage {\n percentage\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n appliesOncePerCustomer\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\",\n \"basicCodeDiscount\": {\n \"endsAt\": null,\n \"customerGets\": {\n \"value\": {\n \"percentage\": 0.4\n }\n }\n }\n}\n\nresponse = client.query(query: query, variables: variables)\n", "node_example": "const client = new shopify.clients.Graphql({session});\nconst data = await client.query({\n data: {\n \"query\": `mutation discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {\n discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n startsAt\n endsAt\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n customerGets {\n value {\n ... on DiscountPercentage {\n percentage\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n appliesOncePerCustomer\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"id\": \"gid://shopify/DiscountCodeNode/206265824\",\n \"basicCodeDiscount\": {\n \"endsAt\": null,\n \"customerGets\": {\n \"value\": {\n \"percentage\": 0.4\n }\n }\n }\n },\n },\n});\n", "php_example": "use Shopify\\Clients\\Graphql;\n\n$client = new Graphql(\"your-development-store.myshopify.com\", $accessToken);\n$query = <<<QUERY\n mutation discountCodeBasicUpdate($id: ID!, $basicCodeDiscount: DiscountCodeBasicInput!) {\n discountCodeBasicUpdate(id: $id, basicCodeDiscount: $basicCodeDiscount) {\n codeDiscountNode {\n codeDiscount {\n ... on DiscountCodeBasic {\n title\n codes(first: 10) {\n nodes {\n code\n }\n }\n startsAt\n endsAt\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n customerGets {\n value {\n ... on DiscountPercentage {\n percentage\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n appliesOncePerCustomer\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"id\" => \"gid://shopify/DiscountCodeNode/206265824\",\n \"basicCodeDiscount\" => [\n \"endsAt\" => null,\n \"customerGets\" => [\n \"value\" => [\n \"percentage\" => 0.4,\n ],\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "id", "description": "The ID of the code discount to update.", "type": { "kind": "SCALAR", "name": "ID", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "ID!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "id", "argValue": " \"gid://shopify/DiscountCodeNode/206265824\"", "typeKind": "MUTATION" }, { "arg": { "name": "basicCodeDiscount", "description": "The input data used to update the code discount.", "type": { "kind": "INPUT_OBJECT", "name": "DiscountCodeBasicInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DiscountCodeBasicInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "basicCodeDiscount", "argValue": " {\"endsAt\":null,\"customerGets\":{\"value\":{\"percentage\":0.4}}}", "typeKind": "MUTATION" } ] } ]