discount Automatic Basic Createmutation
mutation
2024-10latest
Requires Apps must have write
access scope.
Creates a basic automatic discount.
Arguments
The input data used to create the automatic discount.
Was this section helpful?
DiscountAutomaticBasicCreatePayload returns
The created automatic discount.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: discountAutomaticBasicCreate
Query Reference for MUTATION: discountAutomaticBasicCreate
"mutation discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n # DiscountAutomaticNode fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountAutomaticBasicCreate
"{\n \"automaticBasicDiscount\": {\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 \"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 }\n}"
Schema Reference for MUTATION: discountAutomaticBasicCreate
"input DiscountAutomaticBasicInput {\n combinesWith: DiscountCombinesWithInput\n customerGets: DiscountCustomerGetsInput\n endsAt: DateTime\n minimumRequirement: DiscountMinimumRequirementInput\n recurringCycleLimit: Int\n startsAt: DateTime\n title: String\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 DiscountMinimumRequirementInput {\n quantity: DiscountMinimumQuantityInput\n subtotal: DiscountMinimumSubtotalInput\n}\n"
Display Examples for MUTATION: discountAutomaticBasicCreate
[ { "example": { "type_name": "discountautomaticbasiccreate", "title": "Create a basic automatic discount", "description": "Create an automatic discount that offers a $50 discount on all orders over $200, applicable to all customers on all items during the summer months.", "query_string": "mutation discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n customerGets {\n value {\n ... on DiscountAmount {\n amount {\n amount\n currencyCode\n }\n appliesOnEachItem\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}", "variables": { "automaticBasicDiscount": { "title": "$50 off all orders over $200 during the summer of 2022", "startsAt": "2022-06-21T00:00:00Z", "endsAt": "2022-09-21T00:00:00Z", "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": 200 } }, "customerGets": { "value": { "discountAmount": { "amount": 50, "appliesOnEachItem": false } }, "items": { "all": true } } } }, "response": { "data": { "discountAutomaticBasicCreate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371197", "automaticDiscount": { "startsAt": "2022-06-21T00:00:00Z", "endsAt": "2022-09-21T00:00:00Z", "minimumRequirement": { "greaterThanOrEqualToSubtotal": { "amount": "200.0", "currencyCode": "USD" } }, "customerGets": { "value": { "amount": { "amount": "50.0", "currencyCode": "USD" }, "appliesOnEachItem": false }, "items": { "allItems": true } } } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_automatic_basic_create_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 discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) { discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) { automaticDiscountNode { id automaticDiscount { ... on DiscountAutomaticBasic { startsAt endsAt minimumRequirement { ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount currencyCode } } } customerGets { value { ... on DiscountAmount { amount { amount currencyCode } appliesOnEachItem } } items { ... on AllDiscountItems { allItems } } } } } } userErrors { field code message } } }\",\n \"variables\": {\n \"automaticBasicDiscount\": {\n \"title\": \"$50 off all orders over $200 during the summer of 2022\",\n \"startsAt\": \"2022-06-21T00:00:00Z\",\n \"endsAt\": \"2022-09-21T00:00:00Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 200\n }\n },\n \"customerGets\": {\n \"value\": {\n \"discountAmount\": {\n \"amount\": 50,\n \"appliesOnEachItem\": false\n }\n },\n \"items\": {\n \"all\": true\n }\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n customerGets {\n value {\n ... on DiscountAmount {\n amount {\n amount\n currencyCode\n }\n appliesOnEachItem\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"automaticBasicDiscount\": {\n \"title\": \"$50 off all orders over $200 during the summer of 2022\",\n \"startsAt\": \"2022-06-21T00:00:00Z\",\n \"endsAt\": \"2022-09-21T00:00:00Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 200\n }\n },\n \"customerGets\": {\n \"value\": {\n \"discountAmount\": {\n \"amount\": 50,\n \"appliesOnEachItem\": false\n }\n },\n \"items\": {\n \"all\": true\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 discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n customerGets {\n value {\n ... on DiscountAmount {\n amount {\n amount\n currencyCode\n }\n appliesOnEachItem\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"automaticBasicDiscount\": {\n \"title\": \"$50 off all orders over $200 during the summer of 2022\",\n \"startsAt\": \"2022-06-21T00:00:00Z\",\n \"endsAt\": \"2022-09-21T00:00:00Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 200\n }\n },\n \"customerGets\": {\n \"value\": {\n \"discountAmount\": {\n \"amount\": 50,\n \"appliesOnEachItem\": false\n }\n },\n \"items\": {\n \"all\": true\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 discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n customerGets {\n value {\n ... on DiscountAmount {\n amount {\n amount\n currencyCode\n }\n appliesOnEachItem\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"automaticBasicDiscount\": {\n \"title\": \"$50 off all orders over $200 during the summer of 2022\",\n \"startsAt\": \"2022-06-21T00:00:00Z\",\n \"endsAt\": \"2022-09-21T00:00:00Z\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 200\n }\n },\n \"customerGets\": {\n \"value\": {\n \"discountAmount\": {\n \"amount\": 50,\n \"appliesOnEachItem\": false\n }\n },\n \"items\": {\n \"all\": true\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 discountAutomaticBasicCreate($automaticBasicDiscount: DiscountAutomaticBasicInput!) {\n discountAutomaticBasicCreate(automaticBasicDiscount: $automaticBasicDiscount) {\n automaticDiscountNode {\n id\n automaticDiscount {\n ... on DiscountAutomaticBasic {\n startsAt\n endsAt\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n currencyCode\n }\n }\n }\n customerGets {\n value {\n ... on DiscountAmount {\n amount {\n amount\n currencyCode\n }\n appliesOnEachItem\n }\n }\n items {\n ... on AllDiscountItems {\n allItems\n }\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"automaticBasicDiscount\" => [\n \"title\" => \"$50 off all orders over $200 during the summer of 2022\",\n \"startsAt\" => \"2022-06-21T00:00:00Z\",\n \"endsAt\" => \"2022-09-21T00:00:00Z\",\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => 200,\n ],\n ],\n \"customerGets\" => [\n \"value\" => [\n \"discountAmount\" => [\n \"amount\" => 50,\n \"appliesOnEachItem\" => false,\n ],\n ],\n \"items\" => [\n \"all\" => true,\n ],\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "automaticBasicDiscount", "description": "The input data used to create the automatic discount.", "type": { "kind": "INPUT_OBJECT", "name": "DiscountAutomaticBasicInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DiscountAutomaticBasicInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "automaticBasicDiscount", "argValue": " {\"title\":\"$50 off all orders over $200 during the summer of 2022\",\"startsAt\":\"2022-06-21T00:00:00Z\",\"endsAt\":\"2022-09-21T00:00:00Z\",\"minimumRequirement\":{\"subtotal\":{\"greaterThanOrEqualToSubtotal\":200}},\"customerGets\":{\"value\":{\"discountAmount\":{\"amount\":50,\"appliesOnEachItem\":false}},\"items\":{\"all\":true}}}", "typeKind": "MUTATION" } ] } ]