discount Automatic Free Shipping Createmutation
mutation
2024-10latest
Requires Apps must have write
access scope.
Creates a free shipping automatic discount.
Arguments
The input data used to create the automatic discount.
Was this section helpful?
DiscountAutomaticFreeShippingCreatePayload returns
The created automatic discount.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: discountAutomaticFreeShippingCreate
Query Reference for MUTATION: discountAutomaticFreeShippingCreate
"mutation discountAutomaticFreeShippingCreate($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n # DiscountAutomaticNode fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountAutomaticFreeShippingCreate
"{\n \"freeShippingAutomaticDiscount\": {\n \"appliesOnOneTimePurchase\": true,\n \"appliesOnSubscription\": true,\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true,\n \"shippingDiscounts\": true\n },\n \"destination\": {\n \"all\": true,\n \"countries\": {\n \"add\": [\n \"AC\"\n ],\n \"includeRestOfWorld\": true,\n \"remove\": [\n \"AC\"\n ]\n }\n },\n \"endsAt\": \"2019-09-07T15:50:00Z\",\n \"maximumShippingPrice\": \"29.99\",\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: discountAutomaticFreeShippingCreate
"input DiscountAutomaticFreeShippingInput {\n appliesOnOneTimePurchase: Boolean\n appliesOnSubscription: Boolean\n combinesWith: DiscountCombinesWithInput\n destination: DiscountShippingDestinationSelectionInput\n endsAt: DateTime\n maximumShippingPrice: Decimal\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 DiscountShippingDestinationSelectionInput {\n all: Boolean\n countries: DiscountCountriesInput\n}\n\ninput DiscountMinimumRequirementInput {\n quantity: DiscountMinimumQuantityInput\n subtotal: DiscountMinimumSubtotalInput\n}\n"
Display Examples for MUTATION: discountAutomaticFreeShippingCreate
[ { "example": { "type_name": "discountautomaticfreeshippingcreate", "title": "Create an automatic free shipping discount", "description": "Creating an automatic discount", "query_string": "mutation M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "freeShippingAutomaticDiscount": { "title": "New Auto Free Shipping Discount", "startsAt": "2022-05-11T22:30:47Z", "destination": { "all": true }, "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": "1" } }, "combinesWith": { "orderDiscounts": true, "productDiscounts": true } } }, "response": { "data": { "discountAutomaticFreeShippingCreate": { "automaticDiscountNode": { "id": "gid://shopify/DiscountAutomaticNode/1057371196" }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_automatic_free_shipping_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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) { discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) { automaticDiscountNode { id } userErrors { field message } } }\",\n \"variables\": {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true\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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true\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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"freeShippingAutomaticDiscount\": {\n \"title\": \"New Auto Free Shipping Discount\",\n \"startsAt\": \"2022-05-11T22:30:47Z\",\n \"destination\": {\n \"all\": true\n },\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": \"1\"\n }\n },\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true\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 M($freeShippingAutomaticDiscount: DiscountAutomaticFreeShippingInput!) {\n discountAutomaticFreeShippingCreate(freeShippingAutomaticDiscount: $freeShippingAutomaticDiscount) {\n automaticDiscountNode {\n id\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"freeShippingAutomaticDiscount\" => [\n \"title\" => \"New Auto Free Shipping Discount\",\n \"startsAt\" => \"2022-05-11T22:30:47Z\",\n \"destination\" => [\n \"all\" => true,\n ],\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => \"1\",\n ],\n ],\n \"combinesWith\" => [\n \"orderDiscounts\" => true,\n \"productDiscounts\" => true,\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "freeShippingAutomaticDiscount", "description": "The input data used to create the automatic discount.", "type": { "kind": "INPUT_OBJECT", "name": "DiscountAutomaticFreeShippingInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DiscountAutomaticFreeShippingInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "freeShippingAutomaticDiscount", "argValue": " {\"title\":\"New Auto Free Shipping Discount\",\"startsAt\":\"2022-05-11T22:30:47Z\",\"destination\":{\"all\":true},\"minimumRequirement\":{\"subtotal\":{\"greaterThanOrEqualToSubtotal\":\"1\"}},\"combinesWith\":{\"orderDiscounts\":true,\"productDiscounts\":true}}", "typeKind": "MUTATION" } ] } ]