draft Order Calculatemutation
mutation
2024-10latest
Requires write
access scope.
Calculates the properties of a draft order. Useful for determining information such as total taxes or price without actually creating a draft order.
Arguments
The fields for the draft order.
Was this section helpful?
DraftOrderCalculatePayload returns
Anchor to DraftOrderCalculatePayload.calculatedDraftOrdercalculatedDraft Order The calculated properties for a draft order.
The list of errors that occurred from executing the mutation.
Was this section helpful?
Code examples for MUTATION: draftOrderCalculate
Query Reference for MUTATION: draftOrderCalculate
"mutation draftOrderCalculate($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n # CalculatedDraftOrder fields\n }\n userErrors {\n field\n message\n }\n }\n}"
Input Reference for MUTATION: draftOrderCalculate
"{\n \"input\": {\n \"acceptAutomaticDiscounts\": true,\n \"allowDiscountCodesInCheckout\": true,\n \"appliedDiscount\": {\n \"amount\": \"100.57\",\n \"amountWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"description\": \"<your-description>\",\n \"title\": \"<your-title>\",\n \"value\": 1.1,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"country\": \"<your-country>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"province\": \"<your-province>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"discountCodes\": [\n \"<your-discountCodes>\"\n ],\n \"email\": \"<your-email>\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"amountWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"description\": \"<your-description>\",\n \"title\": \"<your-title>\",\n \"value\": 1.1,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"bundleComponents\": [\n {\n \"quantity\": 1,\n \"uuid\": \"<your-uuid>\",\n \"variantId\": \"gid://shopify/<objectName>/10079785100\"\n }\n ],\n \"customAttributes\": [\n {\n \"key\": \"<your-key>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"grams\": 1,\n \"originalUnitPrice\": \"100.57\",\n \"originalUnitPriceWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"<your-sku>\",\n \"taxable\": true,\n \"title\": \"<your-title>\",\n \"uuid\": \"<your-uuid>\",\n \"variantId\": \"gid://shopify/<objectName>/10079785100\",\n \"weight\": {\n \"unit\": \"GRAMS\",\n \"value\": 1.1\n }\n }\n ],\n \"localizationExtensions\": [\n {\n \"key\": \"SHIPPING_CREDENTIAL_BR\",\n \"value\": \"<your-value>\"\n }\n ],\n \"marketRegionCountryCode\": \"AC\",\n \"metafields\": [\n {\n \"description\": \"<your-description>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"key\": \"<your-key>\",\n \"namespace\": \"<your-namespace>\",\n \"type\": \"<your-type>\",\n \"value\": \"<your-value>\"\n }\n ],\n \"note\": \"<your-note>\",\n \"paymentTerms\": {\n \"paymentSchedules\": [\n {\n \"dueAt\": \"2019-09-07T15:50:00Z\",\n \"issuedAt\": \"2019-09-07T15:50:00Z\"\n }\n ],\n \"paymentTermsTemplateId\": \"gid://shopify/<objectName>/10079785100\"\n },\n \"phone\": \"<your-phone>\",\n \"poNumber\": \"<your-poNumber>\",\n \"presentmentCurrencyCode\": \"AED\",\n \"purchasingEntity\": {\n \"customerId\": \"gid://shopify/<objectName>/10079785100\",\n \"purchasingCompany\": {\n \"companyContactId\": \"gid://shopify/<objectName>/10079785100\",\n \"companyId\": \"gid://shopify/<objectName>/10079785100\",\n \"companyLocationId\": \"gid://shopify/<objectName>/10079785100\"\n }\n },\n \"reserveInventoryUntil\": \"2019-09-07T15:50:00Z\",\n \"sessionToken\": \"<your-sessionToken>\",\n \"shippingAddress\": {\n \"address1\": \"<your-address1>\",\n \"address2\": \"<your-address2>\",\n \"city\": \"<your-city>\",\n \"company\": \"<your-company>\",\n \"country\": \"<your-country>\",\n \"countryCode\": \"AC\",\n \"firstName\": \"<your-firstName>\",\n \"id\": \"gid://shopify/<objectName>/10079785100\",\n \"lastName\": \"<your-lastName>\",\n \"phone\": \"<your-phone>\",\n \"province\": \"<your-province>\",\n \"provinceCode\": \"<your-provinceCode>\",\n \"zip\": \"<your-zip>\"\n },\n \"shippingLine\": {\n \"price\": \"100.57\",\n \"priceWithCurrency\": {\n \"amount\": \"29.99\",\n \"currencyCode\": \"AED\"\n },\n \"shippingRateHandle\": \"<your-shippingRateHandle>\",\n \"title\": \"<your-title>\"\n },\n \"sourceName\": \"<your-sourceName>\",\n \"tags\": [\n \"<your-tags>\"\n ],\n \"taxExempt\": true,\n \"transformerFingerprint\": \"<your-transformerFingerprint>\",\n \"useCustomerDefaultAddress\": true,\n \"visibleToCustomer\": true\n }\n}"
Schema Reference for MUTATION: draftOrderCalculate
"input DraftOrderInput {\n acceptAutomaticDiscounts: Boolean\n allowDiscountCodesInCheckout: Boolean\n appliedDiscount: DraftOrderAppliedDiscountInput\n billingAddress: MailingAddressInput\n customAttributes: [AttributeInput!]\n customerId: ID\n discountCodes: [String!]\n email: String\n lineItems: [DraftOrderLineItemInput!]\n localizationExtensions: [LocalizationExtensionInput!]\n marketRegionCountryCode: CountryCode\n metafields: [MetafieldInput!]\n note: String\n paymentTerms: PaymentTermsInput\n phone: String\n poNumber: String\n presentmentCurrencyCode: CurrencyCode\n privateMetafields: [PrivateMetafieldInput!]\n purchasingEntity: PurchasingEntityInput\n reserveInventoryUntil: DateTime\n sessionToken: String\n shippingAddress: MailingAddressInput\n shippingLine: ShippingLineInput\n sourceName: String\n tags: [String!]\n taxExempt: Boolean\n transformerFingerprint: String\n useCustomerDefaultAddress: Boolean\n visibleToCustomer: Boolean\n}\n\ninput DraftOrderAppliedDiscountInput {\n amount: Money\n amountWithCurrency: MoneyInput\n description: String\n title: String\n value: Float!\n valueType: DraftOrderAppliedDiscountType!\n}\n\ninput MailingAddressInput {\n address1: String\n address2: String\n city: String\n company: String\n country: String\n countryCode: CountryCode\n firstName: String\n id: ID\n lastName: String\n phone: String\n province: String\n provinceCode: String\n zip: String\n}\n\ninput AttributeInput {\n key: String!\n value: String!\n}\n\ninput DraftOrderLineItemInput {\n appliedDiscount: DraftOrderAppliedDiscountInput\n bundleComponents: [BundlesDraftOrderBundleLineItemComponentInput!]\n customAttributes: [AttributeInput!]\n grams: Int\n originalUnitPrice: Money\n originalUnitPriceWithCurrency: MoneyInput\n quantity: Int!\n requiresShipping: Boolean\n sku: String\n taxable: Boolean\n title: String\n uuid: String\n variantId: ID\n weight: WeightInput\n}\n\ninput LocalizationExtensionInput {\n key: LocalizationExtensionKey!\n value: String!\n}\n\ninput MetafieldInput {\n description: String\n id: ID\n key: String\n namespace: String\n type: String\n value: String\n}\n\ninput PaymentTermsInput {\n paymentSchedules: [PaymentScheduleInput!]\n paymentTermsTemplateId: ID\n}\n\ninput PrivateMetafieldInput {\n key: String!\n namespace: String!\n owner: ID\n valueInput: PrivateMetafieldValueInput!\n}\n\ninput PurchasingEntityInput {\n customerId: ID\n purchasingCompany: PurchasingCompanyInput\n}\n\ninput ShippingLineInput {\n price: Money\n priceWithCurrency: MoneyInput\n shippingRateHandle: String\n title: String\n}\n"
Display Examples for MUTATION: draftOrderCalculate
[ { "example": { "type_name": "draftordercalculate", "title": "Calculate properties of a draft order", "description": "Calculate the properties of a proposed draft order", "query_string": "mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n customer {\n id\n email\n fullName\n numberOfOrders\n defaultAddress {\n id\n firstName\n lastName\n address1\n address2\n city\n provinceCode\n zip\n countryCodeV2\n }\n taxExempt\n }\n billingAddressMatchesShippingAddress\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n shippingLine {\n id\n custom\n shippingRateHandle\n title\n originalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n presentmentCurrencyCode\n marketName\n marketRegionCountryCode\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "appliedDiscount": { "description": "Loyalty", "value": 5, "valueType": "FIXED_AMOUNT" }, "billingAddress": { "address1": "123 Amoebobacterieae St", "address2": "", "city": "Ottawa", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Bobsen", "phone": "", "provinceCode": "ON", "zip": "K2P0V6" }, "customerId": "gid://shopify/Customer/544365967", "lineItems": [ { "appliedDiscount": { "description": "Promo", "value": 5, "valueType": "FIXED_AMOUNT" }, "customAttributes": [], "originalUnitPrice": 10, "quantity": 1, "requiresShipping": true, "sku": "draft-151", "taxable": true, "title": "151cm", "variantId": "gid://shopify/ProductVariant/43729076", "weight": { "unit": "KILOGRAMS", "value": 1 } }, { "appliedDiscount": null, "customAttributes": [], "originalUnitPrice": "10.0", "quantity": 2, "requiresShipping": true, "sku": null, "taxable": true, "title": "Spring Promo Item", "variantId": null, "weight": { "unit": "KILOGRAMS", "value": 1.2 } } ], "marketRegionCountryCode": null, "presentmentCurrencyCode": "CAD", "shippingAddress": { "address1": "", "address2": "", "city": "", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Smith", "phone": "", "provinceCode": "AB", "zip": "" }, "shippingLine": { "price": "0.0", "title": "Free shipping" }, "taxExempt": false } }, "response": { "data": { "draftOrderCalculate": { "calculatedDraftOrder": { "customer": { "id": "gid://shopify/Customer/544365967", "email": "bob@example.com", "fullName": "Bob Bobsen", "numberOfOrders": "25", "defaultAddress": { "id": "gid://shopify/MailingAddress/544365967?model_name=CustomerAddress", "firstName": "Bob", "lastName": "Bobsen", "address1": "123 Amoebobacterieae St", "address2": "", "city": "Ottawa", "provinceCode": "ON", "zip": "K2P0V6", "countryCodeV2": "CA" }, "taxExempt": false }, "billingAddressMatchesShippingAddress": false, "totalPriceSet": { "presentmentMoney": { "amount": "28.05", "currencyCode": "CAD" }, "shopMoney": { "amount": "21.4", "currencyCode": "USD" } }, "lineItems": [ { "appliedDiscount": { "amountSet": { "presentmentMoney": { "amount": "6.38", "currencyCode": "CAD" }, "shopMoney": { "amount": "5.0", "currencyCode": "USD" } }, "value": 5, "valueType": "FIXED_AMOUNT", "description": "Promo" }, "discountedTotalSet": { "presentmentMoney": { "amount": "6.61", "currencyCode": "CAD" }, "shopMoney": { "amount": "5.0", "currencyCode": "USD" } }, "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "totalVariants": 1 }, "quantity": 1, "requiresShipping": true, "sku": "draft-151", "taxable": true, "title": "Draft", "variantTitle": "151cm", "variant": { "id": "gid://shopify/ProductVariant/43729076" }, "weight": { "value": 1, "unit": "KILOGRAMS" } }, { "appliedDiscount": null, "discountedTotalSet": { "presentmentMoney": { "amount": "25.98", "currencyCode": "CAD" }, "shopMoney": { "amount": "20.0", "currencyCode": "USD" } }, "product": null, "quantity": 2, "requiresShipping": true, "sku": null, "taxable": true, "title": "Spring Promo Item", "variantTitle": null, "variant": null, "weight": { "value": 1.2, "unit": "KILOGRAMS" } } ], "totalTaxSet": { "presentmentMoney": { "amount": "1.84", "currencyCode": "CAD" }, "shopMoney": { "amount": "1.4", "currencyCode": "USD" } }, "totalDiscountsSet": { "presentmentMoney": { "amount": "12.76", "currencyCode": "CAD" }, "shopMoney": { "amount": "10.0", "currencyCode": "USD" } }, "shippingLine": { "id": null, "custom": true, "shippingRateHandle": null, "title": "Free shipping", "originalPriceSet": { "presentmentMoney": { "amount": "0.0", "currencyCode": "CAD" }, "shopMoney": { "amount": "0.0", "currencyCode": "USD" } } }, "presentmentCurrencyCode": "CAD", "marketName": "Primary market", "marketRegionCountryCode": "CA" }, "userErrors": [] } } }, "api_name": "admin", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_calculate_test.rb", "minimum_api_version": null, "maximum_api_version": null, "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 CalculateDraftOrder($input: DraftOrderInput!) { draftOrderCalculate(input: $input) { calculatedDraftOrder { customer { id email fullName numberOfOrders defaultAddress { id firstName lastName address1 address2 city provinceCode zip countryCodeV2 } taxExempt } billingAddressMatchesShippingAddress totalPriceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } lineItems { appliedDiscount { amountSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } value valueType description } discountedTotalSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } product { id title totalVariants } quantity requiresShipping sku taxable title variantTitle variant { id } weight { value unit } } totalTaxSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } totalDiscountsSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } shippingLine { id custom shippingRateHandle title originalPriceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } } presentmentCurrencyCode marketName marketRegionCountryCode } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n customer {\n id\n email\n fullName\n numberOfOrders\n defaultAddress {\n id\n firstName\n lastName\n address1\n address2\n city\n provinceCode\n zip\n countryCodeV2\n }\n taxExempt\n }\n billingAddressMatchesShippingAddress\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n shippingLine {\n id\n custom\n shippingRateHandle\n title\n originalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n presentmentCurrencyCode\n marketName\n marketRegionCountryCode\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n customer {\n id\n email\n fullName\n numberOfOrders\n defaultAddress {\n id\n firstName\n lastName\n address1\n address2\n city\n provinceCode\n zip\n countryCodeV2\n }\n taxExempt\n }\n billingAddressMatchesShippingAddress\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n shippingLine {\n id\n custom\n shippingRateHandle\n title\n originalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n presentmentCurrencyCode\n marketName\n marketRegionCountryCode\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [{\"appliedDiscount\"=>{\"description\"=>\"Promo\", \"value\"=>5, \"valueType\"=>\"FIXED_AMOUNT\"}, \"customAttributes\"=>[], \"originalUnitPrice\"=>10, \"quantity\"=>1, \"requiresShipping\"=>true, \"sku\"=>\"draft-151\", \"taxable\"=>true, \"title\"=>\"151cm\", \"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1}}, {\"appliedDiscount\"=>nil, \"customAttributes\"=>[], \"originalUnitPrice\"=>\"10.0\", \"quantity\"=>2, \"requiresShipping\"=>true, \"sku\"=>nil, \"taxable\"=>true, \"title\"=>\"Spring Promo Item\", \"variantId\"=>nil, \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1.2}}],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n customer {\n id\n email\n fullName\n numberOfOrders\n defaultAddress {\n id\n firstName\n lastName\n address1\n address2\n city\n provinceCode\n zip\n countryCodeV2\n }\n taxExempt\n }\n billingAddressMatchesShippingAddress\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n shippingLine {\n id\n custom\n shippingRateHandle\n title\n originalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n presentmentCurrencyCode\n marketName\n marketRegionCountryCode\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n customer {\n id\n email\n fullName\n numberOfOrders\n defaultAddress {\n id\n firstName\n lastName\n address1\n address2\n city\n provinceCode\n zip\n countryCodeV2\n }\n taxExempt\n }\n billingAddressMatchesShippingAddress\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n shippingLine {\n id\n custom\n shippingRateHandle\n title\n originalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n }\n presentmentCurrencyCode\n marketName\n marketRegionCountryCode\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"appliedDiscount\" => [\n \"description\" => \"Loyalty\",\n \"value\" => 5,\n \"valueType\" => \"FIXED_AMOUNT\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"123 Amoebobacterieae St\",\n \"address2\" => \"\",\n \"city\" => \"Ottawa\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Bobsen\",\n \"phone\" => \"\",\n \"provinceCode\" => \"ON\",\n \"zip\" => \"K2P0V6\",\n ],\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"lineItems\" => [{\"appliedDiscount\"=>{\"description\"=>\"Promo\", \"value\"=>5, \"valueType\"=>\"FIXED_AMOUNT\"}, \"customAttributes\"=>[], \"originalUnitPrice\"=>10, \"quantity\"=>1, \"requiresShipping\"=>true, \"sku\"=>\"draft-151\", \"taxable\"=>true, \"title\"=>\"151cm\", \"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1}}, {\"appliedDiscount\"=>nil, \"customAttributes\"=>[], \"originalUnitPrice\"=>\"10.0\", \"quantity\"=>2, \"requiresShipping\"=>true, \"sku\"=>nil, \"taxable\"=>true, \"title\"=>\"Spring Promo Item\", \"variantId\"=>nil, \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1.2}}],\n \"marketRegionCountryCode\" => null,\n \"presentmentCurrencyCode\" => \"CAD\",\n \"shippingAddress\" => [\n \"address1\" => \"\",\n \"address2\" => \"\",\n \"city\" => \"\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Smith\",\n \"phone\" => \"\",\n \"provinceCode\" => \"AB\",\n \"zip\" => \"\",\n ],\n \"shippingLine\" => [\n \"price\" => \"0.0\",\n \"title\" => \"Free shipping\",\n ],\n \"taxExempt\" => false,\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The fields for the draft order.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"appliedDiscount\":{\"description\":\"Loyalty\",\"value\":5,\"valueType\":\"FIXED_AMOUNT\"},\"billingAddress\":{\"address1\":\"123 Amoebobacterieae St\",\"address2\":\"\",\"city\":\"Ottawa\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Bobsen\",\"phone\":\"\",\"provinceCode\":\"ON\",\"zip\":\"K2P0V6\"},\"customerId\":\"gid://shopify/Customer/544365967\",\"lineItems\":[{\"appliedDiscount\":{\"description\":\"Promo\",\"value\":5,\"valueType\":\"FIXED_AMOUNT\"},\"customAttributes\":[],\"originalUnitPrice\":10,\"quantity\":1,\"requiresShipping\":true,\"sku\":\"draft-151\",\"taxable\":true,\"title\":\"151cm\",\"variantId\":\"gid://shopify/ProductVariant/43729076\",\"weight\":{\"unit\":\"KILOGRAMS\",\"value\":1}},{\"appliedDiscount\":null,\"customAttributes\":[],\"originalUnitPrice\":\"10.0\",\"quantity\":2,\"requiresShipping\":true,\"sku\":null,\"taxable\":true,\"title\":\"Spring Promo Item\",\"variantId\":null,\"weight\":{\"unit\":\"KILOGRAMS\",\"value\":1.2}}],\"marketRegionCountryCode\":null,\"presentmentCurrencyCode\":\"CAD\",\"shippingAddress\":{\"address1\":\"\",\"address2\":\"\",\"city\":\"\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Smith\",\"phone\":\"\",\"provinceCode\":\"AB\",\"zip\":\"\"},\"shippingLine\":{\"price\":\"0.0\",\"title\":\"Free shipping\"},\"taxExempt\":false}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftordercalculate", "title": "Calculate properties of a draft order with markets context", "description": "Calculate the properties of a proposed draft order with market specific context", "query_string": "mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n purchasingEntity {\n ... on Customer {\n firstName\n }\n }\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "marketRegionCountryCode": "CA", "presentmentCurrencyCode": "CAD", "appliedDiscount": { "description": "Loyalty", "value": 5, "valueType": "FIXED_AMOUNT" }, "billingAddress": { "address1": "123 Amoebobacterieae St", "address2": "", "city": "Ottawa", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Bobsen", "phone": "", "provinceCode": "ON", "zip": "K2P0V6" }, "customerId": "gid://shopify/Customer/544365967", "lineItems": [ { "appliedDiscount": { "description": "Promo", "value": 5, "valueType": "FIXED_AMOUNT" }, "customAttributes": [], "originalUnitPrice": 10, "quantity": 1, "requiresShipping": true, "sku": "draft-151", "taxable": true, "title": "151cm", "variantId": "gid://shopify/ProductVariant/43729076", "weight": { "unit": "KILOGRAMS", "value": 1 } }, { "appliedDiscount": null, "customAttributes": [], "originalUnitPrice": "10.0", "quantity": 2, "requiresShipping": true, "sku": null, "taxable": true, "title": "Spring Promo Item", "variantId": null, "weight": { "unit": "KILOGRAMS", "value": 1.2 } } ], "shippingAddress": { "address1": "", "address2": "", "city": "", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Smith", "phone": "", "provinceCode": "AB", "zip": "" }, "shippingLine": { "price": "0.0", "title": "Free shipping" }, "taxExempt": false } }, "response": { "data": { "draftOrderCalculate": { "calculatedDraftOrder": { "purchasingEntity": { "firstName": "Bob" }, "totalPriceSet": { "presentmentMoney": { "amount": "28.05", "currencyCode": "CAD" }, "shopMoney": { "amount": "21.4", "currencyCode": "USD" } }, "lineItems": [ { "appliedDiscount": { "amountSet": { "presentmentMoney": { "amount": "6.38", "currencyCode": "CAD" }, "shopMoney": { "amount": "5.0", "currencyCode": "USD" } }, "value": 5, "valueType": "FIXED_AMOUNT", "description": "Promo" }, "discountedTotalSet": { "presentmentMoney": { "amount": "6.61", "currencyCode": "CAD" }, "shopMoney": { "amount": "5.0", "currencyCode": "USD" } }, "product": { "id": "gid://shopify/Product/108828309", "title": "Draft", "totalVariants": 1 }, "quantity": 1, "requiresShipping": true, "sku": "draft-151", "taxable": true, "title": "Draft", "variantTitle": "151cm", "variant": { "id": "gid://shopify/ProductVariant/43729076" }, "weight": { "value": 1, "unit": "KILOGRAMS" } }, { "appliedDiscount": null, "discountedTotalSet": { "presentmentMoney": { "amount": "25.98", "currencyCode": "CAD" }, "shopMoney": { "amount": "20.0", "currencyCode": "USD" } }, "product": null, "quantity": 2, "requiresShipping": true, "sku": null, "taxable": true, "title": "Spring Promo Item", "variantTitle": null, "variant": null, "weight": { "value": 1.2, "unit": "KILOGRAMS" } } ], "totalTaxSet": { "presentmentMoney": { "amount": "1.84", "currencyCode": "CAD" }, "shopMoney": { "amount": "1.4", "currencyCode": "USD" } }, "totalDiscountsSet": { "presentmentMoney": { "amount": "12.76", "currencyCode": "CAD" }, "shopMoney": { "amount": "10.0", "currencyCode": "USD" } }, "marketName": "Primary market", "marketRegionCountryCode": "CA", "presentmentCurrencyCode": "CAD" }, "userErrors": [] } } }, "api_name": "admin", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_calculate_test.rb", "minimum_api_version": null, "maximum_api_version": null, "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 CalculateDraftOrder($input: DraftOrderInput!) { draftOrderCalculate(input: $input) { calculatedDraftOrder { purchasingEntity { ... on Customer { firstName } } totalPriceSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } lineItems { appliedDiscount { amountSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } value valueType description } discountedTotalSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } product { id title totalVariants } quantity requiresShipping sku taxable title variantTitle variant { id } weight { value unit } } totalTaxSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } totalDiscountsSet { presentmentMoney { amount currencyCode } shopMoney { amount currencyCode } } marketName marketRegionCountryCode presentmentCurrencyCode } userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\",\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n purchasingEntity {\n ... on Customer {\n firstName\n }\n }\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\",\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n purchasingEntity {\n ... on Customer {\n firstName\n }\n }\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\",\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [{\"appliedDiscount\"=>{\"description\"=>\"Promo\", \"value\"=>5, \"valueType\"=>\"FIXED_AMOUNT\"}, \"customAttributes\"=>[], \"originalUnitPrice\"=>10, \"quantity\"=>1, \"requiresShipping\"=>true, \"sku\"=>\"draft-151\", \"taxable\"=>true, \"title\"=>\"151cm\", \"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1}}, {\"appliedDiscount\"=>nil, \"customAttributes\"=>[], \"originalUnitPrice\"=>\"10.0\", \"quantity\"=>2, \"requiresShipping\"=>true, \"sku\"=>nil, \"taxable\"=>true, \"title\"=>\"Spring Promo Item\", \"variantId\"=>nil, \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1.2}}],\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n purchasingEntity {\n ... on Customer {\n firstName\n }\n }\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"marketRegionCountryCode\": \"CA\",\n \"presentmentCurrencyCode\": \"CAD\",\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"123 Amoebobacterieae St\",\n \"address2\": \"\",\n \"city\": \"Ottawa\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Bobsen\",\n \"phone\": \"\",\n \"provinceCode\": \"ON\",\n \"zip\": \"K2P0V6\"\n },\n \"customerId\": \"gid://shopify/Customer/544365967\",\n \"lineItems\": [\n {\n \"appliedDiscount\": {\n \"description\": \"Promo\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": 10,\n \"quantity\": 1,\n \"requiresShipping\": true,\n \"sku\": \"draft-151\",\n \"taxable\": true,\n \"title\": \"151cm\",\n \"variantId\": \"gid://shopify/ProductVariant/43729076\",\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1\n }\n },\n {\n \"appliedDiscount\": null,\n \"customAttributes\": [\n \n ],\n \"originalUnitPrice\": \"10.0\",\n \"quantity\": 2,\n \"requiresShipping\": true,\n \"sku\": null,\n \"taxable\": true,\n \"title\": \"Spring Promo Item\",\n \"variantId\": null,\n \"weight\": {\n \"unit\": \"KILOGRAMS\",\n \"value\": 1.2\n }\n }\n ],\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n calculatedDraftOrder {\n purchasingEntity {\n ... on Customer {\n firstName\n }\n }\n totalPriceSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n lineItems {\n appliedDiscount {\n amountSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n value\n valueType\n description\n }\n discountedTotalSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n product {\n id\n title\n totalVariants\n }\n quantity\n requiresShipping\n sku\n taxable\n title\n variantTitle\n variant {\n id\n }\n weight {\n value\n unit\n }\n }\n totalTaxSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n totalDiscountsSet {\n presentmentMoney {\n amount\n currencyCode\n }\n shopMoney {\n amount\n currencyCode\n }\n }\n marketName\n marketRegionCountryCode\n presentmentCurrencyCode\n }\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"marketRegionCountryCode\" => \"CA\",\n \"presentmentCurrencyCode\" => \"CAD\",\n \"appliedDiscount\" => [\n \"description\" => \"Loyalty\",\n \"value\" => 5,\n \"valueType\" => \"FIXED_AMOUNT\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"123 Amoebobacterieae St\",\n \"address2\" => \"\",\n \"city\" => \"Ottawa\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Bobsen\",\n \"phone\" => \"\",\n \"provinceCode\" => \"ON\",\n \"zip\" => \"K2P0V6\",\n ],\n \"customerId\" => \"gid://shopify/Customer/544365967\",\n \"lineItems\" => [{\"appliedDiscount\"=>{\"description\"=>\"Promo\", \"value\"=>5, \"valueType\"=>\"FIXED_AMOUNT\"}, \"customAttributes\"=>[], \"originalUnitPrice\"=>10, \"quantity\"=>1, \"requiresShipping\"=>true, \"sku\"=>\"draft-151\", \"taxable\"=>true, \"title\"=>\"151cm\", \"variantId\"=>\"gid://shopify/ProductVariant/43729076\", \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1}}, {\"appliedDiscount\"=>nil, \"customAttributes\"=>[], \"originalUnitPrice\"=>\"10.0\", \"quantity\"=>2, \"requiresShipping\"=>true, \"sku\"=>nil, \"taxable\"=>true, \"title\"=>\"Spring Promo Item\", \"variantId\"=>nil, \"weight\"=>{\"unit\"=>\"KILOGRAMS\", \"value\"=>1.2}}],\n \"shippingAddress\" => [\n \"address1\" => \"\",\n \"address2\" => \"\",\n \"city\" => \"\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Smith\",\n \"phone\" => \"\",\n \"provinceCode\" => \"AB\",\n \"zip\" => \"\",\n ],\n \"shippingLine\" => [\n \"price\" => \"0.0\",\n \"title\" => \"Free shipping\",\n ],\n \"taxExempt\" => false,\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The fields for the draft order.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"marketRegionCountryCode\":\"CA\",\"presentmentCurrencyCode\":\"CAD\",\"appliedDiscount\":{\"description\":\"Loyalty\",\"value\":5,\"valueType\":\"FIXED_AMOUNT\"},\"billingAddress\":{\"address1\":\"123 Amoebobacterieae St\",\"address2\":\"\",\"city\":\"Ottawa\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Bobsen\",\"phone\":\"\",\"provinceCode\":\"ON\",\"zip\":\"K2P0V6\"},\"customerId\":\"gid://shopify/Customer/544365967\",\"lineItems\":[{\"appliedDiscount\":{\"description\":\"Promo\",\"value\":5,\"valueType\":\"FIXED_AMOUNT\"},\"customAttributes\":[],\"originalUnitPrice\":10,\"quantity\":1,\"requiresShipping\":true,\"sku\":\"draft-151\",\"taxable\":true,\"title\":\"151cm\",\"variantId\":\"gid://shopify/ProductVariant/43729076\",\"weight\":{\"unit\":\"KILOGRAMS\",\"value\":1}},{\"appliedDiscount\":null,\"customAttributes\":[],\"originalUnitPrice\":\"10.0\",\"quantity\":2,\"requiresShipping\":true,\"sku\":null,\"taxable\":true,\"title\":\"Spring Promo Item\",\"variantId\":null,\"weight\":{\"unit\":\"KILOGRAMS\",\"value\":1.2}}],\"shippingAddress\":{\"address1\":\"\",\"address2\":\"\",\"city\":\"\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Smith\",\"phone\":\"\",\"provinceCode\":\"AB\",\"zip\":\"\"},\"shippingLine\":{\"price\":\"0.0\",\"title\":\"Free shipping\"},\"taxExempt\":false}", "typeKind": "MUTATION" } ] }, { "example": { "type_name": "draftordercalculate", "title": "Calculating a draft order with no line items", "description": "Calculating a draft order with no line items returns a user error", "query_string": "mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n userErrors {\n field\n message\n }\n }\n}", "variables": { "input": { "appliedDiscount": { "description": "Loyalty", "value": 5, "valueType": "FIXED_AMOUNT" }, "billingAddress": { "address1": "", "address2": "", "city": "", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Smith", "phone": "", "provinceCode": "AB", "zip": "" }, "lineItems": [], "marketRegionCountryCode": null, "presentmentCurrencyCode": "CAD", "shippingAddress": { "address1": "", "address2": "", "city": "", "company": "", "countryCode": "CA", "firstName": "Bob", "lastName": "Smith", "phone": "", "provinceCode": "AB", "zip": "" }, "shippingLine": { "price": "0.0", "title": "Free shipping" }, "taxExempt": false } }, "response": { "data": { "draftOrderCalculate": { "userErrors": [ { "field": null, "message": "Add at least 1 product" } ] } } }, "api_name": "admin", "location": "/components/draft_orders/test/unit/graph_api/admin/mutations/draft_order_calculate_test.rb", "minimum_api_version": null, "maximum_api_version": null, "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 CalculateDraftOrder($input: DraftOrderInput!) { draftOrderCalculate(input: $input) { userErrors { field message } } }\",\n \"variables\": {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"lineItems\": [\n \n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\n }\n }\n}'\n", "remix_example": "const { admin } = await authenticate.admin(request);\n\nconst response = await admin.graphql(\n `#graphql\n mutation CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n userErrors {\n field\n message\n }\n }\n }`,\n {\n variables: {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"lineItems\": [\n \n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n userErrors {\n field\n message\n }\n }\n }\nQUERY\n\nvariables = {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"lineItems\": [],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n userErrors {\n field\n message\n }\n }\n }`,\n \"variables\": {\n \"input\": {\n \"appliedDiscount\": {\n \"description\": \"Loyalty\",\n \"value\": 5,\n \"valueType\": \"FIXED_AMOUNT\"\n },\n \"billingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"lineItems\": [\n \n ],\n \"marketRegionCountryCode\": null,\n \"presentmentCurrencyCode\": \"CAD\",\n \"shippingAddress\": {\n \"address1\": \"\",\n \"address2\": \"\",\n \"city\": \"\",\n \"company\": \"\",\n \"countryCode\": \"CA\",\n \"firstName\": \"Bob\",\n \"lastName\": \"Smith\",\n \"phone\": \"\",\n \"provinceCode\": \"AB\",\n \"zip\": \"\"\n },\n \"shippingLine\": {\n \"price\": \"0.0\",\n \"title\": \"Free shipping\"\n },\n \"taxExempt\": false\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 CalculateDraftOrder($input: DraftOrderInput!) {\n draftOrderCalculate(input: $input) {\n userErrors {\n field\n message\n }\n }\n }\nQUERY;\n\n$variables = [\n \"input\" => [\n \"appliedDiscount\" => [\n \"description\" => \"Loyalty\",\n \"value\" => 5,\n \"valueType\" => \"FIXED_AMOUNT\",\n ],\n \"billingAddress\" => [\n \"address1\" => \"\",\n \"address2\" => \"\",\n \"city\" => \"\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Smith\",\n \"phone\" => \"\",\n \"provinceCode\" => \"AB\",\n \"zip\" => \"\",\n ],\n \"lineItems\" => [],\n \"marketRegionCountryCode\" => null,\n \"presentmentCurrencyCode\" => \"CAD\",\n \"shippingAddress\" => [\n \"address1\" => \"\",\n \"address2\" => \"\",\n \"city\" => \"\",\n \"company\" => \"\",\n \"countryCode\" => \"CA\",\n \"firstName\" => \"Bob\",\n \"lastName\" => \"Smith\",\n \"phone\" => \"\",\n \"provinceCode\" => \"AB\",\n \"zip\" => \"\",\n ],\n \"shippingLine\" => [\n \"price\" => \"0.0\",\n \"title\" => \"Free shipping\",\n ],\n \"taxExempt\" => false,\n ],\n];\n\n$response = $client->query([\"query\" => $query, \"variables\" => $variables]);\n" }, "titleStringKey": "variables", "inputVariableEntries": [ { "arg": { "name": "input", "description": "The fields for the draft order.", "type": { "kind": "INPUT_OBJECT", "name": "DraftOrderInput", "list": false, "non_null": true }, "defaultValue": null, "typeSignature": "DraftOrderInput!", "isDeprecated": false, "deprecationReason": null, "kind": "ARGUMENT" }, "key": "input", "argValue": " {\"appliedDiscount\":{\"description\":\"Loyalty\",\"value\":5,\"valueType\":\"FIXED_AMOUNT\"},\"billingAddress\":{\"address1\":\"\",\"address2\":\"\",\"city\":\"\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Smith\",\"phone\":\"\",\"provinceCode\":\"AB\",\"zip\":\"\"},\"lineItems\":[],\"marketRegionCountryCode\":null,\"presentmentCurrencyCode\":\"CAD\",\"shippingAddress\":{\"address1\":\"\",\"address2\":\"\",\"city\":\"\",\"company\":\"\",\"countryCode\":\"CA\",\"firstName\":\"Bob\",\"lastName\":\"Smith\",\"phone\":\"\",\"provinceCode\":\"AB\",\"zip\":\"\"},\"shippingLine\":{\"price\":\"0.0\",\"title\":\"Free shipping\"},\"taxExempt\":false}", "typeKind": "MUTATION" } ] } ]