discount Code Free Shipping Createmutation
mutation
2024-10latest
Requires Apps must have write
access scope.
Creates a free shipping code discount.
Arguments
The input data used to create the code discount.
Was this section helpful?
DiscountCodeFreeShippingCreatePayload returns
The created code discount.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: discountCodeFreeShippingCreate
Query Reference for MUTATION: discountCodeFreeShippingCreate
"mutation discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n # DiscountCodeNode fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: discountCodeFreeShippingCreate
"{\n \"freeShippingCodeDiscount\": {\n \"appliesOnOneTimePurchase\": true,\n \"appliesOnSubscription\": true,\n \"appliesOncePerCustomer\": true,\n \"code\": \"<your-code>\",\n \"combinesWith\": {\n \"orderDiscounts\": true,\n \"productDiscounts\": true,\n \"shippingDiscounts\": true\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 \"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 \"usageLimit\": 1\n }\n}"
Schema Reference for MUTATION: discountCodeFreeShippingCreate
"input DiscountCodeFreeShippingInput {\n appliesOnOneTimePurchase: Boolean\n appliesOnSubscription: Boolean\n appliesOncePerCustomer: Boolean\n code: String\n combinesWith: DiscountCombinesWithInput\n customerSelection: DiscountCustomerSelectionInput\n destination: DiscountShippingDestinationSelectionInput\n endsAt: DateTime\n maximumShippingPrice: Decimal\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 DiscountCustomerSelectionInput {\n all: Boolean\n customerSegments: DiscountCustomerSegmentsInput\n customers: DiscountCustomersInput\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: discountCodeFreeShippingCreate
[ { "example": { "type_name": "discountcodefreeshippingcreate", "title": "Create a discount code for free shipping", "description": "Create a discount code that offers free shipping on orders over $20", "query_string": "mutation discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n maximumShippingPrice {\n amount\n }\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n}", "variables": { "freeShippingCodeDiscount": { "startsAt": "2022-06-22T21:12:07.000Z", "appliesOncePerCustomer": false, "title": "FreeShipping", "code": "FreeShipping", "minimumRequirement": { "subtotal": { "greaterThanOrEqualToSubtotal": 20 } }, "customerSelection": { "all": true }, "destination": { "all": true } } }, "response": { "data": { "discountCodeFreeShippingCreate": { "codeDiscountNode": { "id": "gid://shopify/DiscountCodeNode/1057371199", "codeDiscount": { "title": "FreeShipping", "startsAt": "2022-06-22T21:12:07Z", "endsAt": null, "maximumShippingPrice": null, "customerSelection": { "allCustomers": true }, "destinationSelection": { "allCountries": true }, "minimumRequirement": { "greaterThanOrEqualToSubtotal": { "amount": "20.0" } }, "codes": { "nodes": [ { "code": "FreeShipping" } ] } } }, "userErrors": [] } } }, "api_name": "admin", "minimum_api_version": "2023-10", "maximum_api_version": "unstable", "location": "/components/pricing/test/unit/graph_api/admin/mutations/discount_code_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 discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) { discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) { codeDiscountNode { id codeDiscount { ... on DiscountCodeFreeShipping { title startsAt endsAt maximumShippingPrice { amount } customerSelection { ... on DiscountCustomerAll { allCustomers } } destinationSelection { ... on DiscountCountryAll { allCountries } } minimumRequirement { ... on DiscountMinimumSubtotal { greaterThanOrEqualToSubtotal { amount } } } codes(first: 2) { nodes { code } } } } } userErrors { field code message } } }\",\n \"variables\": {\n \"freeShippingCodeDiscount\": {\n \"startsAt\": \"2022-06-22T21:12:07.000Z\",\n \"appliesOncePerCustomer\": false,\n \"title\": \"FreeShipping\",\n \"code\": \"FreeShipping\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 20.0\n }\n },\n \"customerSelection\": {\n \"all\": true\n },\n \"destination\": {\n \"all\": true\n }\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n maximumShippingPrice {\n amount\n }\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n {\n variables: {\n \"freeShippingCodeDiscount\": {\n \"startsAt\": \"2022-06-22T21:12:07.000Z\",\n \"appliesOncePerCustomer\": false,\n \"title\": \"FreeShipping\",\n \"code\": \"FreeShipping\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 20.0\n }\n },\n \"customerSelection\": {\n \"all\": true\n },\n \"destination\": {\n \"all\": 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 discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n maximumShippingPrice {\n amount\n }\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"freeShippingCodeDiscount\": {\n \"startsAt\": \"2022-06-22T21:12:07.000Z\",\n \"appliesOncePerCustomer\": false,\n \"title\": \"FreeShipping\",\n \"code\": \"FreeShipping\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 20.0\n }\n },\n \"customerSelection\": {\n \"all\": true\n },\n \"destination\": {\n \"all\": 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 discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n maximumShippingPrice {\n amount\n }\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }`,\n \"variables\": {\n \"freeShippingCodeDiscount\": {\n \"startsAt\": \"2022-06-22T21:12:07.000Z\",\n \"appliesOncePerCustomer\": false,\n \"title\": \"FreeShipping\",\n \"code\": \"FreeShipping\",\n \"minimumRequirement\": {\n \"subtotal\": {\n \"greaterThanOrEqualToSubtotal\": 20.0\n }\n },\n \"customerSelection\": {\n \"all\": true\n },\n \"destination\": {\n \"all\": 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 discountCodeFreeShippingCreate($freeShippingCodeDiscount: DiscountCodeFreeShippingInput!) {\n discountCodeFreeShippingCreate(freeShippingCodeDiscount: $freeShippingCodeDiscount) {\n codeDiscountNode {\n id\n codeDiscount {\n ... on DiscountCodeFreeShipping {\n title\n startsAt\n endsAt\n maximumShippingPrice {\n amount\n }\n customerSelection {\n ... on DiscountCustomerAll {\n allCustomers\n }\n }\n destinationSelection {\n ... on DiscountCountryAll {\n allCountries\n }\n }\n minimumRequirement {\n ... on DiscountMinimumSubtotal {\n greaterThanOrEqualToSubtotal {\n amount\n }\n }\n }\n codes(first: 2) {\n nodes {\n code\n }\n }\n }\n }\n }\n userErrors {\n field\n code\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"freeShippingCodeDiscount\" => [\n \"startsAt\" => \"2022-06-22T21:12:07.000Z\",\n \"appliesOncePerCustomer\" => false,\n \"title\" => \"FreeShipping\",\n \"code\" => \"FreeShipping\",\n \"minimumRequirement\" => [\n \"subtotal\" => [\n \"greaterThanOrEqualToSubtotal\" => 20.0,\n ],\n ],\n \"customerSelection\" => [\n \"all\" => true,\n ],\n \"destination\" => [\n \"all\" => true,\n ],\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "freeShippingCodeDiscount", "description": "The input data used to create the code discount.", "type": { "kind": "INPUT_OBJECT", "name": "DiscountCodeFreeShippingInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DiscountCodeFreeShippingInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "freeShippingCodeDiscount", "argValue": " {\"startsAt\":\"2022-06-22T21:12:07.000Z\",\"appliesOncePerCustomer\":false,\"title\":\"FreeShipping\",\"code\":\"FreeShipping\",\"minimumRequirement\":{\"subtotal\":{\"greaterThanOrEqualToSubtotal\":20}},\"customerSelection\":{\"all\":true},\"destination\":{\"all\":true}}", "typeKind": "MUTATION" } ] } ]