From 252bcf177e3e04fd650be029573de117142ce584 Mon Sep 17 00:00:00 2001 From: Muna Rahman Date: Wed, 30 Apr 2025 16:23:35 -0400 Subject: [PATCH 1/3] Update to include discount class filtering --- .../src/generate_cart_run.graphql.liquid | 3 + .../default/src/generate_cart_run.liquid | 201 +++++++++------- .../default/src/generate_cart_run.test.liquid | 216 ++++++++++++++++-- .../src/generate_delivery_run.graphql.liquid | 3 + .../default/src/generate_delivery_run.liquid | 23 +- .../src/generate_delivery_run.test.liquid | 111 +++++++-- .../src/generate_cart_run.graphql.liquid | 3 + .../discount/default/src/generate_cart_run.rs | 42 +++- .../src/generate_delivery_run.graphql.liquid | 3 + .../default/src/generate_delivery_run.rs | 11 +- 10 files changed, 489 insertions(+), 127 deletions(-) diff --git a/discounts/javascript/discount/default/src/generate_cart_run.graphql.liquid b/discounts/javascript/discount/default/src/generate_cart_run.graphql.liquid index 148989d0..b1f8d29c 100644 --- a/discounts/javascript/discount/default/src/generate_cart_run.graphql.liquid +++ b/discounts/javascript/discount/default/src/generate_cart_run.graphql.liquid @@ -9,4 +9,7 @@ query CartInput { } } } + discount { + discountClasses + } } diff --git a/discounts/javascript/discount/default/src/generate_cart_run.liquid b/discounts/javascript/discount/default/src/generate_cart_run.liquid index 252d2498..891bd2c6 100644 --- a/discounts/javascript/discount/default/src/generate_cart_run.liquid +++ b/discounts/javascript/discount/default/src/generate_cart_run.liquid @@ -2,6 +2,7 @@ // @ts-check import { + DiscountClass, OrderDiscountSelectionStrategy, ProductDiscountSelectionStrategy, } from '../generated/api'; @@ -20,63 +21,85 @@ export function generateCartRun(input) { if (!input.cart.lines.length) { throw new Error('No cart lines found'); } + + const hasOrderDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Order + ); + + const hasProductDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Product + ); + + if (!hasOrderDiscountClass && !hasProductDiscountClass) { + return { operations: [] }; + } + const maxCartLine = input.cart.lines.reduce((maxLine, line) => { if (line.cost.subtotalAmount.amount > maxLine.cost.subtotalAmount.amount) { return line; } return maxLine; }, input.cart.lines[0]); - return { - operations: [ - { - orderDiscountsAdd: { - candidates: [ - { - message: '10% OFF ORDER', - targets: [ - { - orderSubtotal: { - excludedCartLineIds: [], - }, - }, - ], - value: { - percentage: { - value: 10, + + const operations = []; + + if(hasOrderDiscountClass) { + operations.push({ + orderDiscountsAdd: { + candidates: [ + { + message: '10% OFF ORDER', + targets: [ + { + orderSubtotal: { + excludedCartLineIds: [], }, }, + ], + value: { + percentage: { + value: 10, + }, }, - ], - selectionStrategy: OrderDiscountSelectionStrategy.First, - }, + }, + ], + selectionStrategy: OrderDiscountSelectionStrategy.First, }, - { - productDiscountsAdd: { - candidates: [ - { - message: '20% OFF PRODUCT', - targets: [ - { - cartLine: { - id: maxCartLine.id, - }, - }, - ], - value: { - percentage: { - value: 20, + }); + } + + if (hasProductDiscountClass) { + operations.push({ + productDiscountsAdd: { + candidates: [ + { + message: '20% OFF PRODUCT', + targets: [ + { + cartLine: { + id: maxCartLine.id, }, }, + ], + value: { + percentage: { + value: 20, + }, }, - ], - selectionStrategy: ProductDiscountSelectionStrategy.First, - }, + }, + ], + selectionStrategy: ProductDiscountSelectionStrategy.First, }, - ], + }); + } + + return { + operations, }; } {%- elsif flavor contains "typescript" -%} import { + DiscountClass, OrderDiscountSelectionStrategy, ProductDiscountSelectionStrategy, CartInput, @@ -88,6 +111,18 @@ export function generateCartRun(input: CartInput): CartLinesDiscountsGenerateRun throw new Error('No cart lines found'); } + const hasOrderDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Order + ); + + const hasProductDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Product + ); + + if (!hasOrderDiscountClass && !hasProductDiscountClass) { + return { operations: [] }; + } + const maxCartLine = input.cart.lines.reduce((maxLine, line) => { if (line.cost.subtotalAmount.amount > maxLine.cost.subtotalAmount.amount) { return line; @@ -95,53 +130,61 @@ export function generateCartRun(input: CartInput): CartLinesDiscountsGenerateRun return maxLine; }, input.cart.lines[0]); - return { - operations: [ - { - orderDiscountsAdd: { - candidates: [ - { - message: '10% OFF ORDER', - targets: [ - { - orderSubtotal: { - excludedCartLineIds: [], - }, - }, - ], - value: { - percentage: { - value: 10, + const operations: CartLinesDiscountsGenerateRunResult['operations'] = []; + + if (hasOrderDiscountClass) { + operations.push({ + orderDiscountsAdd: { + candidates: [ + { + message: '10% OFF ORDER', + targets: [ + { + orderSubtotal: { + excludedCartLineIds: [], }, }, + ], + value: { + percentage: { + value: 10, + }, }, - ], - selectionStrategy: OrderDiscountSelectionStrategy.First, - }, - }, - { - productDiscountsAdd: { - candidates: [ - { - message: '20% OFF PRODUCT', - targets: [ - { - cartLine: { - id: maxCartLine.id, - }, - }, - ], - value: { - percentage: { - value: 20, + }, + ], + selectionStrategy: OrderDiscountSelectionStrategy.First, + } + }); + } + + if (hasProductDiscountClass) { + operations.push({ + productDiscountsAdd: { + candidates: [ + { + message: '20% OFF PRODUCT', + targets: [ + { + cartLine: { + id: maxCartLine.id, }, }, + ], + value: { + percentage: { + value: 20, + }, }, - ], - selectionStrategy: ProductDiscountSelectionStrategy.First, - }, + }, + ], + selectionStrategy: ProductDiscountSelectionStrategy.First, }, - ], + }); + }; + + return { + operations, }; } + {%- endif -%} diff --git a/discounts/javascript/discount/default/src/generate_cart_run.test.liquid b/discounts/javascript/discount/default/src/generate_cart_run.test.liquid index cb8cf6ec..ba42fe5a 100644 --- a/discounts/javascript/discount/default/src/generate_cart_run.test.liquid +++ b/discounts/javascript/discount/default/src/generate_cart_run.test.liquid @@ -5,6 +5,7 @@ import { generateCartRun } from "./generate_cart_run"; import { OrderDiscountSelectionStrategy, ProductDiscountSelectionStrategy, + DiscountClass, } from "../generated/api"; /** @@ -12,23 +13,114 @@ import { */ describe("generateCartRun", () => { - it("returns a product and order discount", () => { + const baseInput = { + cart: { + lines: [ + { + id: "gid://shopify/CartLine/0", + cost: { + subtotalAmount: { + amount: 100 + }, + }, + }, + ], + }, + discount: { + discountClasses: [], + } + }; + + it("returns empty operations when no discount classes are present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [], + }, + }; + + const result = generateCartRun(input); + expect(result.operations).toHaveLength(0); + }); + + it("returns only order discount when only order discount class is present", () => { const input = { - cart: { - lines: [ + ...baseInput, + discount: { + discountClasses: [DiscountClass.Order], + }, + }; + + const result = generateCartRun(input); + expect(result.operations).toHaveLength(1); + expect(result.operations[0]).toMatchObject({ + orderDiscountsAdd: { + candidates: [ { - id: "gid://shopify/CartLine/0", - cost: { - subtotalAmount: 100, + message: "10% OFF ORDER", + targets: [ + { + orderSubtotal: { + excludedCartLineIds: [], + }, + }, + ], + value: { + percentage: { + value: 10, + }, }, }, ], + selectionStrategy: OrderDiscountSelectionStrategy.First, + }, + }); + }); + + it("returns only product discount when only product discount class is present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Product], }, }; const result = generateCartRun(input); + expect(result.operations).toHaveLength(1); + expect(result.operations[0]).toMatchObject({ + productDiscountsAdd: { + candidates: [ + { + message: "20% OFF PRODUCT", + targets: [ + { + cartLine: { + id: "gid://shopify/CartLine/0", + }, + }, + ], + value: { + percentage: { + value: 20, + }, + }, + }, + ], + selectionStrategy: ProductDiscountSelectionStrategy.First, + }, + }); + }); + + it("returns both discounts when both discount classes are present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Order, DiscountClass.Product], + }, + }; - expect(result.operations.length).toBe(2); + const result = generateCartRun(input); + expect(result.operations).toHaveLength(2); expect(result.operations[0]).toMatchObject({ orderDiscountsAdd: { candidates: [ @@ -83,28 +175,120 @@ import { generateCartRun } from "./generate_cart_run"; import { OrderDiscountSelectionStrategy, ProductDiscountSelectionStrategy, + DiscountClass, CartInput, CartLinesDiscountsGenerateRunResult } from "../generated/api"; describe("generateCartRun", () => { - it("returns a product and order discount", () => { + const baseInput: CartInput = { + cart: { + lines: [ + { + id: "gid://shopify/CartLine/0", + cost: { + subtotalAmount: { + amount: 100 + }, + }, + }, + ], + }, + discount: { + discountClasses: [], + } + }; + + it("returns empty operations when no discount classes are present", () => { + const input: CartInput = { + ...baseInput, + discount: { + discountClasses: [], + }, + }; + + const result = generateCartRun(input); + expect(result.operations).toHaveLength(0); + }); + + it("returns only order discount when only order discount class is present", () => { const input: CartInput = { - cart: { - lines: [ + ...baseInput, + discount: { + discountClasses: [DiscountClass.Order], + }, + }; + + const result = generateCartRun(input); + expect(result.operations).toHaveLength(1); + expect(result.operations[0]).toMatchObject({ + orderDiscountsAdd: { + candidates: [ { - id: "gid://shopify/CartLine/0", - cost: { - subtotalAmount: 100, + message: "10% OFF ORDER", + targets: [ + { + orderSubtotal: { + excludedCartLineIds: [], + }, + }, + ], + value: { + percentage: { + value: 10, + }, }, }, ], + selectionStrategy: OrderDiscountSelectionStrategy.First, + }, + }); + }); + + it("returns only product discount when only product discount class is present", () => { + const input: CartInput = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Product], }, }; - const result: CartLinesDiscountsGenerateRunResult = generateCartRun(input); + const result = generateCartRun(input); + expect(result.operations).toHaveLength(1); + expect(result.operations[0]).toMatchObject({ + productDiscountsAdd: { + candidates: [ + { + message: "20% OFF PRODUCT", + targets: [ + { + cartLine: { + id: "gid://shopify/CartLine/0", + }, + }, + ], + value: { + percentage: { + value: 20, + }, + }, + }, + ], + selectionStrategy: ProductDiscountSelectionStrategy.First, + }, + }); + }); - expect(result.operations.length).toBe(2); + it("returns both discounts when both discount classes are present", () => { + const input: CartInput = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Order, DiscountClass.Product], + }, + }; + + const result = generateCartRun(input); + expect(result.operations).toHaveLength(2); expect(result.operations[0]).toMatchObject({ orderDiscountsAdd: { candidates: [ @@ -152,4 +336,4 @@ describe("generateCartRun", () => { }); }); }); -{%- endif -%} \ No newline at end of file +{%- endif -%} diff --git a/discounts/javascript/discount/default/src/generate_delivery_run.graphql.liquid b/discounts/javascript/discount/default/src/generate_delivery_run.graphql.liquid index ff7c2878..12a8d131 100644 --- a/discounts/javascript/discount/default/src/generate_delivery_run.graphql.liquid +++ b/discounts/javascript/discount/default/src/generate_delivery_run.graphql.liquid @@ -4,4 +4,7 @@ query DeliveryInput { id } } + discount { + discountClasses + } } diff --git a/discounts/javascript/discount/default/src/generate_delivery_run.liquid b/discounts/javascript/discount/default/src/generate_delivery_run.liquid index 59524b82..37f4d562 100644 --- a/discounts/javascript/discount/default/src/generate_delivery_run.liquid +++ b/discounts/javascript/discount/default/src/generate_delivery_run.liquid @@ -1,7 +1,10 @@ {%- if flavor contains "vanilla-js" -%} // @ts-check -import { DeliveryDiscountSelectionStrategy} from '../generated/api'; +import { + DeliveryDiscountSelectionStrategy, + DiscountClass, +} from "../generated/api"; /** * @typedef {import("../generated/api").Input} RunInput @@ -17,6 +20,15 @@ export function generateDeliveryRun(input) { if (!firstDeliveryGroup) { throw new Error('No delivery groups found'); } + + const hasShippingDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Shipping + ); + + if (!hasShippingDiscountClass) { + return { operations: [] }; + } + return { operations: [ { @@ -49,6 +61,7 @@ import { DeliveryDiscountSelectionStrategy, DeliveryInput, CartDeliveryOptionsDiscountsGenerateRunResult, + DiscountClass } from '../generated/api'; export function generateDeliveryRun( @@ -59,6 +72,14 @@ export function generateDeliveryRun( throw new Error('No delivery groups found'); } + const hasShippingDiscountClass = input.discount.discountClasses.includes( + DiscountClass.Shipping + ); + + if (!hasShippingDiscountClass) { + return { operations: [] }; + } + return { operations: [ { diff --git a/discounts/javascript/discount/default/src/generate_delivery_run.test.liquid b/discounts/javascript/discount/default/src/generate_delivery_run.test.liquid index a6ec200f..37cdff20 100644 --- a/discounts/javascript/discount/default/src/generate_delivery_run.test.liquid +++ b/discounts/javascript/discount/default/src/generate_delivery_run.test.liquid @@ -4,6 +4,7 @@ import { describe, it, expect } from "vitest"; import { generateDeliveryRun } from "./generate_delivery_run"; import { DeliveryDiscountSelectionStrategy, + DiscountClass, } from "../generated/api"; /** @@ -12,20 +13,41 @@ import { */ describe("generateDeliveryRun", () => { - it("returns a delivery discount", () => { - const input = /** @type {DeliveryInput} */ ({ - cart: { - deliveryGroups: [ - { - id: "gid://shopify/DeliveryGroup/0", - }, - ], + const baseInput = { + cart: { + deliveryGroups: [ + { + id: "gid://shopify/DeliveryGroup/0", + }, + ], + }, + discount: { + discountClasses: [], + } + }; + + it("returns empty operations when no discount classes are present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [], }, - }); + }; const result = generateDeliveryRun(input); + expect(result.operations).toHaveLength(0); + }); + + it("returns delivery discount when shipping discount class is present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Shipping], + }, + }; - expect(result.operations.length).toBe(1); + const result = generateDeliveryRun(input); + expect(result.operations).toHaveLength(1); expect(result.operations[0]).toMatchObject({ deliveryDiscountsAdd: { candidates: [ @@ -49,6 +71,19 @@ describe("generateDeliveryRun", () => { }, }); }); + + it("throws error when no delivery groups are present", () => { + const input = { + cart: { + deliveryGroups: [], + }, + discount: { + discountClasses: [DiscountClass.Shipping], + }, + }; + + expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found'); + }); }); {%- elsif flavor contains "typescript" -%} import { describe, it, expect } from "vitest"; @@ -56,25 +91,46 @@ import { describe, it, expect } from "vitest"; import { generateDeliveryRun } from "./generate_delivery_run"; import { DeliveryDiscountSelectionStrategy, - DeliveryInput, + DiscountClass, CartDeliveryOptionsDiscountsGenerateRunResult } from "../generated/api"; describe("generateDeliveryRun", () => { - it("returns a delivery discount", () => { - const input: DeliveryInput = { - cart: { - deliveryGroups: [ - { - id: "gid://shopify/DeliveryGroup/0", - }, - ], + const baseInput = { + cart: { + deliveryGroups: [ + { + id: "gid://shopify/DeliveryGroup/0", + }, + ], + }, + discount: { + discountClasses: [], + } + }; + + it("returns empty operations when no discount classes are present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [], }, }; const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input); + expect(result.operations).toHaveLength(0); + }); + + it("returns delivery discount when shipping discount class is present", () => { + const input = { + ...baseInput, + discount: { + discountClasses: [DiscountClass.Shipping], + }, + }; - expect(result.operations.length).toBe(1); + const result: CartDeliveryOptionsDiscountsGenerateRunResult = generateDeliveryRun(input); + expect(result.operations).toHaveLength(1); expect(result.operations[0]).toMatchObject({ deliveryDiscountsAdd: { candidates: [ @@ -98,5 +154,18 @@ describe("generateDeliveryRun", () => { }, }); }); + + it("throws error when no delivery groups are present", () => { + const input = { + cart: { + deliveryGroups: [], + }, + discount: { + discountClasses: [DiscountClass.Shipping], + }, + }; + + expect(() => generateDeliveryRun(input)).toThrow('No delivery groups found'); + }); }); -{%- endif -%} \ No newline at end of file +{%- endif -%} diff --git a/discounts/rust/discount/default/src/generate_cart_run.graphql.liquid b/discounts/rust/discount/default/src/generate_cart_run.graphql.liquid index 43e918a4..e981bac5 100644 --- a/discounts/rust/discount/default/src/generate_cart_run.graphql.liquid +++ b/discounts/rust/discount/default/src/generate_cart_run.graphql.liquid @@ -9,4 +9,7 @@ query Input { } } } + discount { + discountClasses + } } diff --git a/discounts/rust/discount/default/src/generate_cart_run.rs b/discounts/rust/discount/default/src/generate_cart_run.rs index 90557c36..f1141e6b 100644 --- a/discounts/rust/discount/default/src/generate_cart_run.rs +++ b/discounts/rust/discount/default/src/generate_cart_run.rs @@ -9,7 +9,7 @@ use cart_lines_discounts_generate_run::output::{ ProductDiscountSelectionStrategy, ProductDiscountsAddOperation, }; -use cart_lines_discounts_generate_run::input::ResponseData; +use cart_lines_discounts_generate_run::input::{DiscountClass, ResponseData}; #[shopify_function_target( target = "cartLinesDiscountsGenerateRun", @@ -30,9 +30,25 @@ fn generate_cart_run(input: ResponseData) -> Result Result Result Result { + let has_shipping_discount_class = input + .discount + .discount_classes + .contains(&DiscountClass::SHIPPING); + + if !has_shipping_discount_class { + return Ok(CartDeliveryOptionsDiscountsGenerateRunResult { operations: vec![] }); + } + let first_delivery_group = input .cart .delivery_groups From d6c611a01ac8e8de4f0d3c4d5a3ef9af28c3307a Mon Sep 17 00:00:00 2001 From: Muna Rahman Date: Wed, 30 Apr 2025 16:55:04 -0400 Subject: [PATCH 2/3] Remove network folders --- .../javascript/network/default/.gitignore | 4 - .../network/default/package.json.liquid | 31 - .../javascript/network/default/schema.graphql | 5172 ----------------- .../default/shopify.extension.toml.liquid | 32 - .../src/generate_cart_fetch.graphql.liquid | 3 - .../default/src/generate_cart_fetch.liquid | 65 - .../src/generate_cart_run.graphql.liquid | 6 - .../default/src/generate_cart_run.liquid | 37 - .../generate_delivery_fetch.graphql.liquid | 3 - .../src/generate_delivery_fetch.liquid | 64 - .../src/generate_delivery_run.graphql.liquid | 11 - .../default/src/generate_delivery_run.liquid | 39 - .../src/generate_discount_default.test.liquid | 8 - .../network/default/src/index.liquid | 4 - .../network/default/src/network.test.liquid | 167 - .../javascript/network/default/vite.config.js | 1 - discounts/rust/network/default/.gitignore | 2 - .../rust/network/default/Cargo.toml.liquid | 18 - discounts/rust/network/default/README.md | 16 - discounts/rust/network/default/schema.graphql | 5170 ---------------- .../default/shopify.extension.toml.liquid | 33 - .../src/generate_cart_fetch.graphql.liquid | 3 - .../default/src/generate_cart_fetch.rs | 91 - .../src/generate_cart_run.graphql.liquid | 17 - .../network/default/src/generate_cart_run.rs | 67 - .../generate_delivery_fetch.graphql.liquid | 3 - .../default/src/generate_delivery_fetch.rs | 91 - .../src/generate_delivery_run.graphql.liquid | 11 - .../default/src/generate_delivery_run.rs | 61 - discounts/rust/network/default/src/main.rs | 10 - 30 files changed, 11240 deletions(-) delete mode 100644 discounts/javascript/network/default/.gitignore delete mode 100644 discounts/javascript/network/default/package.json.liquid delete mode 100644 discounts/javascript/network/default/schema.graphql delete mode 100644 discounts/javascript/network/default/shopify.extension.toml.liquid delete mode 100644 discounts/javascript/network/default/src/generate_cart_fetch.graphql.liquid delete mode 100644 discounts/javascript/network/default/src/generate_cart_fetch.liquid delete mode 100644 discounts/javascript/network/default/src/generate_cart_run.graphql.liquid delete mode 100644 discounts/javascript/network/default/src/generate_cart_run.liquid delete mode 100644 discounts/javascript/network/default/src/generate_delivery_fetch.graphql.liquid delete mode 100644 discounts/javascript/network/default/src/generate_delivery_fetch.liquid delete mode 100644 discounts/javascript/network/default/src/generate_delivery_run.graphql.liquid delete mode 100644 discounts/javascript/network/default/src/generate_delivery_run.liquid delete mode 100644 discounts/javascript/network/default/src/generate_discount_default.test.liquid delete mode 100644 discounts/javascript/network/default/src/index.liquid delete mode 100644 discounts/javascript/network/default/src/network.test.liquid delete mode 100644 discounts/javascript/network/default/vite.config.js delete mode 100644 discounts/rust/network/default/.gitignore delete mode 100644 discounts/rust/network/default/Cargo.toml.liquid delete mode 100644 discounts/rust/network/default/README.md delete mode 100644 discounts/rust/network/default/schema.graphql delete mode 100644 discounts/rust/network/default/shopify.extension.toml.liquid delete mode 100644 discounts/rust/network/default/src/generate_cart_fetch.graphql.liquid delete mode 100644 discounts/rust/network/default/src/generate_cart_fetch.rs delete mode 100644 discounts/rust/network/default/src/generate_cart_run.graphql.liquid delete mode 100644 discounts/rust/network/default/src/generate_cart_run.rs delete mode 100644 discounts/rust/network/default/src/generate_delivery_fetch.graphql.liquid delete mode 100644 discounts/rust/network/default/src/generate_delivery_fetch.rs delete mode 100644 discounts/rust/network/default/src/generate_delivery_run.graphql.liquid delete mode 100644 discounts/rust/network/default/src/generate_delivery_run.rs delete mode 100644 discounts/rust/network/default/src/main.rs diff --git a/discounts/javascript/network/default/.gitignore b/discounts/javascript/network/default/.gitignore deleted file mode 100644 index aa0926aa..00000000 --- a/discounts/javascript/network/default/.gitignore +++ /dev/null @@ -1,4 +0,0 @@ -node_modules/ -dist/ -.env -*.log diff --git a/discounts/javascript/network/default/package.json.liquid b/discounts/javascript/network/default/package.json.liquid deleted file mode 100644 index 956d682f..00000000 --- a/discounts/javascript/network/default/package.json.liquid +++ /dev/null @@ -1,31 +0,0 @@ -{ - "name": "{{handle}}", - "version": "0.0.1", - "license": "UNLICENSED", - "scripts": { - "shopify": "npm exec -- shopify", - "typegen": "npm exec -- shopify app function typegen", - "build": "npm exec -- shopify app function build", - "preview": "npm exec -- shopify app function run", - "test": "vitest" - }, - "codegen": { - "schema": "schema.graphql", - "documents": "src/*.graphql", - "generates": { - "./generated/api.ts": { - "plugins": [ - "typescript", - "typescript-operations" - ] - } - }, - "config": { - "omitOperationSuffix": true - } - }, - "devDependencies": { - "vitest": "^0.29.8" - } - } - \ No newline at end of file diff --git a/discounts/javascript/network/default/schema.graphql b/discounts/javascript/network/default/schema.graphql deleted file mode 100644 index 2c2f866b..00000000 --- a/discounts/javascript/network/default/schema.graphql +++ /dev/null @@ -1,5172 +0,0 @@ -schema { - query: Input - mutation: MutationRoot -} - -""" -Only allow the field to be queried when targeting one of the specified targets. -""" -directive @restrictTarget(only: [String!]!) on FIELD_DEFINITION - -""" -Scale the Functions resource limits based on the field's length. -""" -directive @scaleLimits(rate: Float!) on FIELD_DEFINITION - -""" -Requires that exactly one field must be supplied and that field must not be `null`. -""" -directive @oneOf on INPUT_OBJECT - -""" -A discount code that is associated with a discount candidate. -""" -input AssociatedDiscountCode { - """ - The discount code. - """ - code: String! -} - -""" -Represents a generic custom attribute, such as whether an order is a customer's first. -""" -type Attribute { - """ - The key or name of the attribute. For example, `"customersFirstOrder"`. - """ - key: String! - - """ - The value of the attribute. For example, `"true"`. - """ - value: String -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type BuyerIdentity { - """ - The customer associated with the cart. - """ - customer: Customer - - """ - The email address of the buyer that's interacting with the cart. - """ - email: String - - """ - Whether the buyer authenticated with a customer account. - """ - isAuthenticated: Boolean! - - """ - The phone number of the buyer that's interacting with the cart. - """ - phone: String - - """ - The purchasing company associated with the cart. - """ - purchasingCompany: PurchasingCompany -} - -""" -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. -""" -type Cart { - """ - The attributes associated with the cart. Attributes are represented as key-value pairs. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - Information about the buyer that is interacting with the cart. - """ - buyerIdentity: BuyerIdentity - - """ - The costs that the buyer will pay at checkout. - """ - cost: CartCost! - - """ - A list of lines containing information about the items that can be delivered. - """ - deliverableLines: [DeliverableCartLine!]! - - """ - The delivery groups available for the cart based on the buyer's shipping address. - """ - deliveryGroups: [CartDeliveryGroup!]! - - """ - A list of lines containing information about the items the customer intends to purchase. - """ - lines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The localized fields available for the cart. - """ - localizedFields( - """ - The keys of the localized fields to retrieve. - """ - keys: [LocalizedFieldKey!]! = [] - ): [LocalizedField!]! -} - -""" -The cost that the buyer will pay at checkout. -""" -type CartCost { - """ - The amount, before taxes and discounts, for the customer to pay. - """ - subtotalAmount: MoneyV2! - - """ - The total amount for the customer to pay. - """ - totalAmount: MoneyV2! - - """ - The duty amount for the customer to pay at checkout. - """ - totalDutyAmount: MoneyV2 - - """ - The tax amount for the customer to pay at checkout. - """ - totalTaxAmount: MoneyV2 -} - -""" -Information about the options available for one or more line items to be delivered to a specific address. -""" -type CartDeliveryGroup { - """ - A list of cart lines for the delivery group. - """ - cartLines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The destination address for the delivery group. - """ - deliveryAddress: MailingAddress - - """ - The delivery options available for the delivery group. - """ - deliveryOptions: [CartDeliveryOption!]! - - """ - Unique identifier for the delivery group. - """ - id: ID! - - """ - Information about the delivery option the buyer has selected. - """ - selectedDeliveryOption: CartDeliveryOption -} - -""" -Information about a delivery option. -""" -type CartDeliveryOption { - """ - The code of the delivery option. - """ - code: String - - """ - The cost for the delivery option. - """ - cost: MoneyV2! - - """ - The method for the delivery option. - """ - deliveryMethodType: DeliveryMethod! - - """ - The description of the delivery option. - """ - description: String - - """ - The unique identifier of the delivery option. - """ - handle: Handle! - - """ - The title of the delivery option. - """ - title: String -} - -""" -Represents information about the merchandise in the cart. -""" -type CartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The cost of the merchandise line that the buyer will pay at checkout. - """ - cost: CartLineCost! - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! - - """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. - """ - sellingPlanAllocation: SellingPlanAllocation -} - -""" -The cost of the merchandise line that the buyer will pay at checkout. -""" -type CartLineCost { - """ - The amount of the merchandise line. - """ - amountPerQuantity: MoneyV2! - - """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. - """ - compareAtAmountPerQuantity: MoneyV2 - - """ - The cost of the merchandise line before line-level discounts. - """ - subtotalAmount: MoneyV2! - - """ - The total cost of the merchandise line. - """ - totalAmount: MoneyV2! -} - -""" -The condition for checking the minimum quantity of products across a group of cart lines. -""" -input CartLineMinimumQuantity { - """ - Cart line IDs with a merchandise line price that's included to calculate the - minimum quantity purchased to receive the discount. - """ - ids: [ID!]! - - """ - The minimum quantity of a product. - """ - minimumQuantity: Int! -} - -""" -The condition for checking the minimum subtotal of products across a group of cart lines. -""" -input CartLineMinimumSubtotal { - """ - Cart line IDs with a merchandise line price that's included to calculate the - minimum subtotal purchased to receive the discount. - """ - ids: [ID!]! - - """ - The minimum subtotal amount of the product. - """ - minimumAmount: Decimal! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. -""" -input CartLineTarget { - """ - The ID of the targeted cart line. - """ - id: ID! - - """ - The number of line items that are being discounted. - The default value is `null`, which represents the quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -The operations that can be performed to apply discounts to the cart. -""" -input CartOperation @oneOf { - """ - A list of valid discount codes that correspond to external discounts. This can - only be used by Functions with network access. - """ - addDiscountCodeValidations: ValidDiscountCodes - - """ - A group of order discounts that share a selection strategy. - """ - addOrderDiscounts: OrderDiscounts - - """ - A group of product discounts that share a selection strategy. - """ - addProductDiscounts: ProductDiscounts -} - -""" -Represents whether the product is a member of the given collection. -""" -type CollectionMembership { - """ - The ID of the collection. - """ - collectionId: ID! - - """ - Whether the product is a member of the collection. - """ - isMember: Boolean! -} - -""" -Represents information about a company which is also a customer of the shop. -""" -type Company implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's main point of contact. -""" -type CompanyContact { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was created in Shopify. - """ - createdAt: DateTime! - - """ - The ID of the company. - """ - id: ID! - - """ - The company contact's locale (language). - """ - locale: String - - """ - The company contact's job title. - """ - title: String - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's location. -""" -type CompanyLocation implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - The preferred locale of the company location. - """ - locale: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company location. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was last modified. - """ - updatedAt: DateTime! -} - -""" -The condition to apply the discount candidate. -""" -input Condition @oneOf { - """ - The condition for checking the minimum quantity of products across a group of cart lines. - """ - cartLineMinimumQuantity: CartLineMinimumQuantity - - """ - The condition for checking the minimum subtotal of products across a group of cart lines. - """ - cartLineMinimumSubtotal: CartLineMinimumSubtotal - - """ - The condition for checking the minimum subtotal amount of the order. - """ - orderMinimumSubtotal: OrderMinimumSubtotal -} - -""" -A country. -""" -type Country { - """ - The ISO code of the country. - """ - isoCode: CountryCode! -} - -""" -The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. -If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision -of another country. For example, the territories associated with Spain are represented by the country code `ES`, -and the territories associated with the United States of America are represented by the country code `US`. -""" -enum CountryCode { - """ - Ascension Island. - """ - AC - - """ - Andorra. - """ - AD - - """ - United Arab Emirates. - """ - AE - - """ - Afghanistan. - """ - AF - - """ - Antigua & Barbuda. - """ - AG - - """ - Anguilla. - """ - AI - - """ - Albania. - """ - AL - - """ - Armenia. - """ - AM - - """ - Netherlands Antilles. - """ - AN - - """ - Angola. - """ - AO - - """ - Argentina. - """ - AR - - """ - Austria. - """ - AT - - """ - Australia. - """ - AU - - """ - Aruba. - """ - AW - - """ - Åland Islands. - """ - AX - - """ - Azerbaijan. - """ - AZ - - """ - Bosnia & Herzegovina. - """ - BA - - """ - Barbados. - """ - BB - - """ - Bangladesh. - """ - BD - - """ - Belgium. - """ - BE - - """ - Burkina Faso. - """ - BF - - """ - Bulgaria. - """ - BG - - """ - Bahrain. - """ - BH - - """ - Burundi. - """ - BI - - """ - Benin. - """ - BJ - - """ - St. Barthélemy. - """ - BL - - """ - Bermuda. - """ - BM - - """ - Brunei. - """ - BN - - """ - Bolivia. - """ - BO - - """ - Caribbean Netherlands. - """ - BQ - - """ - Brazil. - """ - BR - - """ - Bahamas. - """ - BS - - """ - Bhutan. - """ - BT - - """ - Bouvet Island. - """ - BV - - """ - Botswana. - """ - BW - - """ - Belarus. - """ - BY - - """ - Belize. - """ - BZ - - """ - Canada. - """ - CA - - """ - Cocos (Keeling) Islands. - """ - CC - - """ - Congo - Kinshasa. - """ - CD - - """ - Central African Republic. - """ - CF - - """ - Congo - Brazzaville. - """ - CG - - """ - Switzerland. - """ - CH - - """ - Côte d’Ivoire. - """ - CI - - """ - Cook Islands. - """ - CK - - """ - Chile. - """ - CL - - """ - Cameroon. - """ - CM - - """ - China. - """ - CN - - """ - Colombia. - """ - CO - - """ - Costa Rica. - """ - CR - - """ - Cuba. - """ - CU - - """ - Cape Verde. - """ - CV - - """ - Curaçao. - """ - CW - - """ - Christmas Island. - """ - CX - - """ - Cyprus. - """ - CY - - """ - Czechia. - """ - CZ - - """ - Germany. - """ - DE - - """ - Djibouti. - """ - DJ - - """ - Denmark. - """ - DK - - """ - Dominica. - """ - DM - - """ - Dominican Republic. - """ - DO - - """ - Algeria. - """ - DZ - - """ - Ecuador. - """ - EC - - """ - Estonia. - """ - EE - - """ - Egypt. - """ - EG - - """ - Western Sahara. - """ - EH - - """ - Eritrea. - """ - ER - - """ - Spain. - """ - ES - - """ - Ethiopia. - """ - ET - - """ - Finland. - """ - FI - - """ - Fiji. - """ - FJ - - """ - Falkland Islands. - """ - FK - - """ - Faroe Islands. - """ - FO - - """ - France. - """ - FR - - """ - Gabon. - """ - GA - - """ - United Kingdom. - """ - GB - - """ - Grenada. - """ - GD - - """ - Georgia. - """ - GE - - """ - French Guiana. - """ - GF - - """ - Guernsey. - """ - GG - - """ - Ghana. - """ - GH - - """ - Gibraltar. - """ - GI - - """ - Greenland. - """ - GL - - """ - Gambia. - """ - GM - - """ - Guinea. - """ - GN - - """ - Guadeloupe. - """ - GP - - """ - Equatorial Guinea. - """ - GQ - - """ - Greece. - """ - GR - - """ - South Georgia & South Sandwich Islands. - """ - GS - - """ - Guatemala. - """ - GT - - """ - Guinea-Bissau. - """ - GW - - """ - Guyana. - """ - GY - - """ - Hong Kong SAR. - """ - HK - - """ - Heard & McDonald Islands. - """ - HM - - """ - Honduras. - """ - HN - - """ - Croatia. - """ - HR - - """ - Haiti. - """ - HT - - """ - Hungary. - """ - HU - - """ - Indonesia. - """ - ID - - """ - Ireland. - """ - IE - - """ - Israel. - """ - IL - - """ - Isle of Man. - """ - IM - - """ - India. - """ - IN - - """ - British Indian Ocean Territory. - """ - IO - - """ - Iraq. - """ - IQ - - """ - Iran. - """ - IR - - """ - Iceland. - """ - IS - - """ - Italy. - """ - IT - - """ - Jersey. - """ - JE - - """ - Jamaica. - """ - JM - - """ - Jordan. - """ - JO - - """ - Japan. - """ - JP - - """ - Kenya. - """ - KE - - """ - Kyrgyzstan. - """ - KG - - """ - Cambodia. - """ - KH - - """ - Kiribati. - """ - KI - - """ - Comoros. - """ - KM - - """ - St. Kitts & Nevis. - """ - KN - - """ - North Korea. - """ - KP - - """ - South Korea. - """ - KR - - """ - Kuwait. - """ - KW - - """ - Cayman Islands. - """ - KY - - """ - Kazakhstan. - """ - KZ - - """ - Laos. - """ - LA - - """ - Lebanon. - """ - LB - - """ - St. Lucia. - """ - LC - - """ - Liechtenstein. - """ - LI - - """ - Sri Lanka. - """ - LK - - """ - Liberia. - """ - LR - - """ - Lesotho. - """ - LS - - """ - Lithuania. - """ - LT - - """ - Luxembourg. - """ - LU - - """ - Latvia. - """ - LV - - """ - Libya. - """ - LY - - """ - Morocco. - """ - MA - - """ - Monaco. - """ - MC - - """ - Moldova. - """ - MD - - """ - Montenegro. - """ - ME - - """ - St. Martin. - """ - MF - - """ - Madagascar. - """ - MG - - """ - North Macedonia. - """ - MK - - """ - Mali. - """ - ML - - """ - Myanmar (Burma). - """ - MM - - """ - Mongolia. - """ - MN - - """ - Macao SAR. - """ - MO - - """ - Martinique. - """ - MQ - - """ - Mauritania. - """ - MR - - """ - Montserrat. - """ - MS - - """ - Malta. - """ - MT - - """ - Mauritius. - """ - MU - - """ - Maldives. - """ - MV - - """ - Malawi. - """ - MW - - """ - Mexico. - """ - MX - - """ - Malaysia. - """ - MY - - """ - Mozambique. - """ - MZ - - """ - Namibia. - """ - NA - - """ - New Caledonia. - """ - NC - - """ - Niger. - """ - NE - - """ - Norfolk Island. - """ - NF - - """ - Nigeria. - """ - NG - - """ - Nicaragua. - """ - NI - - """ - Netherlands. - """ - NL - - """ - Norway. - """ - NO - - """ - Nepal. - """ - NP - - """ - Nauru. - """ - NR - - """ - Niue. - """ - NU - - """ - New Zealand. - """ - NZ - - """ - Oman. - """ - OM - - """ - Panama. - """ - PA - - """ - Peru. - """ - PE - - """ - French Polynesia. - """ - PF - - """ - Papua New Guinea. - """ - PG - - """ - Philippines. - """ - PH - - """ - Pakistan. - """ - PK - - """ - Poland. - """ - PL - - """ - St. Pierre & Miquelon. - """ - PM - - """ - Pitcairn Islands. - """ - PN - - """ - Palestinian Territories. - """ - PS - - """ - Portugal. - """ - PT - - """ - Paraguay. - """ - PY - - """ - Qatar. - """ - QA - - """ - Réunion. - """ - RE - - """ - Romania. - """ - RO - - """ - Serbia. - """ - RS - - """ - Russia. - """ - RU - - """ - Rwanda. - """ - RW - - """ - Saudi Arabia. - """ - SA - - """ - Solomon Islands. - """ - SB - - """ - Seychelles. - """ - SC - - """ - Sudan. - """ - SD - - """ - Sweden. - """ - SE - - """ - Singapore. - """ - SG - - """ - St. Helena. - """ - SH - - """ - Slovenia. - """ - SI - - """ - Svalbard & Jan Mayen. - """ - SJ - - """ - Slovakia. - """ - SK - - """ - Sierra Leone. - """ - SL - - """ - San Marino. - """ - SM - - """ - Senegal. - """ - SN - - """ - Somalia. - """ - SO - - """ - Suriname. - """ - SR - - """ - South Sudan. - """ - SS - - """ - São Tomé & Príncipe. - """ - ST - - """ - El Salvador. - """ - SV - - """ - Sint Maarten. - """ - SX - - """ - Syria. - """ - SY - - """ - Eswatini. - """ - SZ - - """ - Tristan da Cunha. - """ - TA - - """ - Turks & Caicos Islands. - """ - TC - - """ - Chad. - """ - TD - - """ - French Southern Territories. - """ - TF - - """ - Togo. - """ - TG - - """ - Thailand. - """ - TH - - """ - Tajikistan. - """ - TJ - - """ - Tokelau. - """ - TK - - """ - Timor-Leste. - """ - TL - - """ - Turkmenistan. - """ - TM - - """ - Tunisia. - """ - TN - - """ - Tonga. - """ - TO - - """ - Türkiye. - """ - TR - - """ - Trinidad & Tobago. - """ - TT - - """ - Tuvalu. - """ - TV - - """ - Taiwan. - """ - TW - - """ - Tanzania. - """ - TZ - - """ - Ukraine. - """ - UA - - """ - Uganda. - """ - UG - - """ - U.S. Outlying Islands. - """ - UM - - """ - United States. - """ - US - - """ - Uruguay. - """ - UY - - """ - Uzbekistan. - """ - UZ - - """ - Vatican City. - """ - VA - - """ - St. Vincent & Grenadines. - """ - VC - - """ - Venezuela. - """ - VE - - """ - British Virgin Islands. - """ - VG - - """ - Vietnam. - """ - VN - - """ - Vanuatu. - """ - VU - - """ - Wallis & Futuna. - """ - WF - - """ - Samoa. - """ - WS - - """ - Kosovo. - """ - XK - - """ - Yemen. - """ - YE - - """ - Mayotte. - """ - YT - - """ - South Africa. - """ - ZA - - """ - Zambia. - """ - ZM - - """ - Zimbabwe. - """ - ZW - - """ - Unknown Region. - """ - ZZ -} - -""" -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. -""" -enum CurrencyCode { - """ - United Arab Emirates Dirham (AED). - """ - AED - - """ - Afghan Afghani (AFN). - """ - AFN - - """ - Albanian Lek (ALL). - """ - ALL - - """ - Armenian Dram (AMD). - """ - AMD - - """ - Netherlands Antillean Guilder. - """ - ANG - - """ - Angolan Kwanza (AOA). - """ - AOA - - """ - Argentine Pesos (ARS). - """ - ARS - - """ - Australian Dollars (AUD). - """ - AUD - - """ - Aruban Florin (AWG). - """ - AWG - - """ - Azerbaijani Manat (AZN). - """ - AZN - - """ - Bosnia and Herzegovina Convertible Mark (BAM). - """ - BAM - - """ - Barbadian Dollar (BBD). - """ - BBD - - """ - Bangladesh Taka (BDT). - """ - BDT - - """ - Bulgarian Lev (BGN). - """ - BGN - - """ - Bahraini Dinar (BHD). - """ - BHD - - """ - Burundian Franc (BIF). - """ - BIF - - """ - Bermudian Dollar (BMD). - """ - BMD - - """ - Brunei Dollar (BND). - """ - BND - - """ - Bolivian Boliviano (BOB). - """ - BOB - - """ - Brazilian Real (BRL). - """ - BRL - - """ - Bahamian Dollar (BSD). - """ - BSD - - """ - Bhutanese Ngultrum (BTN). - """ - BTN - - """ - Botswana Pula (BWP). - """ - BWP - - """ - Belarusian Ruble (BYN). - """ - BYN - - """ - Belarusian Ruble (BYR). - """ - BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") - - """ - Belize Dollar (BZD). - """ - BZD - - """ - Canadian Dollars (CAD). - """ - CAD - - """ - Congolese franc (CDF). - """ - CDF - - """ - Swiss Francs (CHF). - """ - CHF - - """ - Chilean Peso (CLP). - """ - CLP - - """ - Chinese Yuan Renminbi (CNY). - """ - CNY - - """ - Colombian Peso (COP). - """ - COP - - """ - Costa Rican Colones (CRC). - """ - CRC - - """ - Cape Verdean escudo (CVE). - """ - CVE - - """ - Czech Koruny (CZK). - """ - CZK - - """ - Djiboutian Franc (DJF). - """ - DJF - - """ - Danish Kroner (DKK). - """ - DKK - - """ - Dominican Peso (DOP). - """ - DOP - - """ - Algerian Dinar (DZD). - """ - DZD - - """ - Egyptian Pound (EGP). - """ - EGP - - """ - Eritrean Nakfa (ERN). - """ - ERN - - """ - Ethiopian Birr (ETB). - """ - ETB - - """ - Euro (EUR). - """ - EUR - - """ - Fijian Dollars (FJD). - """ - FJD - - """ - Falkland Islands Pounds (FKP). - """ - FKP - - """ - United Kingdom Pounds (GBP). - """ - GBP - - """ - Georgian Lari (GEL). - """ - GEL - - """ - Ghanaian Cedi (GHS). - """ - GHS - - """ - Gibraltar Pounds (GIP). - """ - GIP - - """ - Gambian Dalasi (GMD). - """ - GMD - - """ - Guinean Franc (GNF). - """ - GNF - - """ - Guatemalan Quetzal (GTQ). - """ - GTQ - - """ - Guyanese Dollar (GYD). - """ - GYD - - """ - Hong Kong Dollars (HKD). - """ - HKD - - """ - Honduran Lempira (HNL). - """ - HNL - - """ - Croatian Kuna (HRK). - """ - HRK - - """ - Haitian Gourde (HTG). - """ - HTG - - """ - Hungarian Forint (HUF). - """ - HUF - - """ - Indonesian Rupiah (IDR). - """ - IDR - - """ - Israeli New Shekel (NIS). - """ - ILS - - """ - Indian Rupees (INR). - """ - INR - - """ - Iraqi Dinar (IQD). - """ - IQD - - """ - Iranian Rial (IRR). - """ - IRR - - """ - Icelandic Kronur (ISK). - """ - ISK - - """ - Jersey Pound. - """ - JEP - - """ - Jamaican Dollars (JMD). - """ - JMD - - """ - Jordanian Dinar (JOD). - """ - JOD - - """ - Japanese Yen (JPY). - """ - JPY - - """ - Kenyan Shilling (KES). - """ - KES - - """ - Kyrgyzstani Som (KGS). - """ - KGS - - """ - Cambodian Riel. - """ - KHR - - """ - Kiribati Dollar (KID). - """ - KID - - """ - Comorian Franc (KMF). - """ - KMF - - """ - South Korean Won (KRW). - """ - KRW - - """ - Kuwaiti Dinar (KWD). - """ - KWD - - """ - Cayman Dollars (KYD). - """ - KYD - - """ - Kazakhstani Tenge (KZT). - """ - KZT - - """ - Laotian Kip (LAK). - """ - LAK - - """ - Lebanese Pounds (LBP). - """ - LBP - - """ - Sri Lankan Rupees (LKR). - """ - LKR - - """ - Liberian Dollar (LRD). - """ - LRD - - """ - Lesotho Loti (LSL). - """ - LSL - - """ - Lithuanian Litai (LTL). - """ - LTL - - """ - Latvian Lati (LVL). - """ - LVL - - """ - Libyan Dinar (LYD). - """ - LYD - - """ - Moroccan Dirham. - """ - MAD - - """ - Moldovan Leu (MDL). - """ - MDL - - """ - Malagasy Ariary (MGA). - """ - MGA - - """ - Macedonia Denar (MKD). - """ - MKD - - """ - Burmese Kyat (MMK). - """ - MMK - - """ - Mongolian Tugrik. - """ - MNT - - """ - Macanese Pataca (MOP). - """ - MOP - - """ - Mauritanian Ouguiya (MRU). - """ - MRU - - """ - Mauritian Rupee (MUR). - """ - MUR - - """ - Maldivian Rufiyaa (MVR). - """ - MVR - - """ - Malawian Kwacha (MWK). - """ - MWK - - """ - Mexican Pesos (MXN). - """ - MXN - - """ - Malaysian Ringgits (MYR). - """ - MYR - - """ - Mozambican Metical. - """ - MZN - - """ - Namibian Dollar. - """ - NAD - - """ - Nigerian Naira (NGN). - """ - NGN - - """ - Nicaraguan Córdoba (NIO). - """ - NIO - - """ - Norwegian Kroner (NOK). - """ - NOK - - """ - Nepalese Rupee (NPR). - """ - NPR - - """ - New Zealand Dollars (NZD). - """ - NZD - - """ - Omani Rial (OMR). - """ - OMR - - """ - Panamian Balboa (PAB). - """ - PAB - - """ - Peruvian Nuevo Sol (PEN). - """ - PEN - - """ - Papua New Guinean Kina (PGK). - """ - PGK - - """ - Philippine Peso (PHP). - """ - PHP - - """ - Pakistani Rupee (PKR). - """ - PKR - - """ - Polish Zlotych (PLN). - """ - PLN - - """ - Paraguayan Guarani (PYG). - """ - PYG - - """ - Qatari Rial (QAR). - """ - QAR - - """ - Romanian Lei (RON). - """ - RON - - """ - Serbian dinar (RSD). - """ - RSD - - """ - Russian Rubles (RUB). - """ - RUB - - """ - Rwandan Franc (RWF). - """ - RWF - - """ - Saudi Riyal (SAR). - """ - SAR - - """ - Solomon Islands Dollar (SBD). - """ - SBD - - """ - Seychellois Rupee (SCR). - """ - SCR - - """ - Sudanese Pound (SDG). - """ - SDG - - """ - Swedish Kronor (SEK). - """ - SEK - - """ - Singapore Dollars (SGD). - """ - SGD - - """ - Saint Helena Pounds (SHP). - """ - SHP - - """ - Sierra Leonean Leone (SLL). - """ - SLL - - """ - Somali Shilling (SOS). - """ - SOS - - """ - Surinamese Dollar (SRD). - """ - SRD - - """ - South Sudanese Pound (SSP). - """ - SSP - - """ - Sao Tome And Principe Dobra (STD). - """ - STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") - - """ - Sao Tome And Principe Dobra (STN). - """ - STN - - """ - Syrian Pound (SYP). - """ - SYP - - """ - Swazi Lilangeni (SZL). - """ - SZL - - """ - Thai baht (THB). - """ - THB - - """ - Tajikistani Somoni (TJS). - """ - TJS - - """ - Turkmenistani Manat (TMT). - """ - TMT - - """ - Tunisian Dinar (TND). - """ - TND - - """ - Tongan Pa'anga (TOP). - """ - TOP - - """ - Turkish Lira (TRY). - """ - TRY - - """ - Trinidad and Tobago Dollars (TTD). - """ - TTD - - """ - Taiwan Dollars (TWD). - """ - TWD - - """ - Tanzanian Shilling (TZS). - """ - TZS - - """ - Ukrainian Hryvnia (UAH). - """ - UAH - - """ - Ugandan Shilling (UGX). - """ - UGX - - """ - United States Dollars (USD). - """ - USD - - """ - Uruguayan Pesos (UYU). - """ - UYU - - """ - Uzbekistan som (UZS). - """ - UZS - - """ - Venezuelan Bolivares (VED). - """ - VED - - """ - Venezuelan Bolivares (VEF). - """ - VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") - - """ - Venezuelan Bolivares Soberanos (VES). - """ - VES - - """ - Vietnamese đồng (VND). - """ - VND - - """ - Vanuatu Vatu (VUV). - """ - VUV - - """ - Samoan Tala (WST). - """ - WST - - """ - Central African CFA Franc (XAF). - """ - XAF - - """ - East Caribbean Dollar (XCD). - """ - XCD - - """ - West African CFA franc (XOF). - """ - XOF - - """ - CFP Franc (XPF). - """ - XPF - - """ - Unrecognized currency. - """ - XXX - - """ - Yemeni Rial (YER). - """ - YER - - """ - South African Rand (ZAR). - """ - ZAR - - """ - Zambian Kwacha (ZMW). - """ - ZMW -} - -""" -A custom product. -""" -type CustomProduct { - """ - Whether the merchandise is a gift card. - """ - isGiftCard: Boolean! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents a customer with the shop. -""" -type Customer implements HasMetafields { - """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. - """ - amountSpent: MoneyV2! - - """ - The customer’s name, email or phone number. - """ - displayName: String! - - """ - The customer’s email address. - """ - email: String - - """ - The customer's first name. - """ - firstName: String - - """ - Whether the customer has any of the given tags. - """ - hasAnyTag( - """ - The tags to search for. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the customer has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A unique identifier for the customer. - """ - id: ID! - - """ - The customer's last name. - """ - lastName: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The number of orders made by the customer. - """ - numberOfOrders: Int! -} - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. -For example, September 7, 2019 is represented as `"2019-07-16"`. -""" -scalar Date - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. -For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is -represented as `"2019-09-07T15:50:00Z`". -""" -scalar DateTime - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the date and time but not the timezone which is determined from context. - -For example, "2018-01-01T00:00:00". -""" -scalar DateTimeWithoutTimezone - -""" -A signed decimal number, which supports arbitrary precision and is serialized as a string. - -Example values: `"29.99"`, `"29.999"`. -""" -scalar Decimal - -""" -Represents information about the merchandise in the cart. -""" -type DeliverableCartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! -} - -""" -The delivery discount candidate to be applied. -""" -input DeliveryDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The discount message. - """ - message: String - - """ - The targets of the delivery discount candidate. - """ - targets: [DeliveryDiscountCandidateTarget!]! - - """ - The value of the delivery discount candidate. - """ - value: DeliveryDiscountCandidateValue! -} - -""" -The target of the delivery discount candidate. -""" -input DeliveryDiscountCandidateTarget @oneOf { - """ - The target delivery group. - """ - deliveryGroup: DeliveryGroupTarget - - """ - The target delivery option. - """ - deliveryOption: DeliveryOptionTarget -} - -""" -The delivery discount candidate value. -""" -input DeliveryDiscountCandidateValue @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of delivery discount candidates. -""" -enum DeliveryDiscountSelectionStrategy { - """ - Apply all delivery discount candidates with conditions that are satisfied. This does not override - discount combination or stacking rules. - """ - ALL -} - -""" -A group of delivery discounts that share a selection strategy. -""" -input DeliveryDiscounts { - """ - The list of delivery discount candidates to be applied. - """ - candidates: [DeliveryDiscountCandidate!]! - - """ - The strategy that's applied to the list of discounts. - """ - selectionStrategy: DeliveryDiscountSelectionStrategy! -} - -""" -The target delivery group. -""" -input DeliveryGroupTarget { - """ - The ID of the target delivery group. - """ - id: ID! -} - -""" -List of different delivery method types. -""" -enum DeliveryMethod { - """ - Local Delivery. - """ - LOCAL - - """ - None. - """ - NONE - - """ - Shipping to a Pickup Point. - """ - PICKUP_POINT - - """ - Local Pickup. - """ - PICK_UP - - """ - Retail. - """ - RETAIL - - """ - Shipping. - """ - SHIPPING -} - -""" -The operations that can be performed to apply discounts to the delivery lines. -""" -input DeliveryOperation @oneOf { - """ - A group of delivery discounts that share a selection strategy. - """ - addDeliveryDiscounts: DeliveryDiscounts - - """ - A list of valid discount codes that correspond to external discounts. This can - only be used by Functions with network access. - """ - addDiscountCodeValidations: ValidDiscountCodes -} - -""" -The target delivery option. -""" -input DeliveryOptionTarget { - """ - The handle of the target delivery option. - """ - handle: Handle! -} - -""" -The discount that invoked the Function. -""" -type Discount implements HasMetafields { - """ - The discount classes supported by the discount node. - """ - discountClasses: [DiscountClass!]! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -The [discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) -that's used to control how discounts can be combined. -""" -enum DiscountClass { - """ - The discount is combined with an - [order discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - ORDER - - """ - The discount is combined with a - [product discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - PRODUCT - - """ - The discount is combined with a - [shipping discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - SHIPPING -} - -""" -A fixed amount value. -""" -input FixedAmount { - """ - The fixed amount value of the discount, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! -} - -""" -The cart.fetch target result. Refer to [network access] -(https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. -""" -input FunctionCartFetchResult { - """ - The http request. - """ - request: HttpRequest -} - -""" -The cart.run target result. -""" -input FunctionCartRunResult { - """ - The list of operations to apply discounts to the cart. - """ - operations: [CartOperation!]! -} - -""" -The delivery.fetch target result. Refer to -[network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. -""" -input FunctionDeliveryFetchResult { - """ - The http request. - """ - request: HttpRequest -} - -""" -The delivery.run target result. -""" -input FunctionDeliveryRunResult { - """ - The list of operations to apply discounts to the delivery lines. - """ - operations: [DeliveryOperation!]! -} - -""" -Represents a gate configuration. -""" -type GateConfiguration implements HasMetafields { - """ - An optional string identifier. - """ - appId: String - - """ - A non-unique string used to group gate configurations. - """ - handle: Handle - - """ - The ID of the gate configuration. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents a connection from a subject to a gate configuration. -""" -type GateSubject { - """ - The bound gate configuration. - """ - configuration( - """ - The appId of the gate configurations to search for. - """ - appId: String @deprecated(reason: "Use GateSubject.handle to filter gates instead.") - ): GateConfiguration! - - """ - The ID of the gate subject. - """ - id: ID! -} - -""" -A function-scoped handle to a refer a resource. -The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. -Example value: `"10079785100"` -""" -scalar Handle - -""" -Gate subjects associated to the specified resource. -""" -interface HasGates { - """ - Returns active gate subjects bound to the resource. - """ - gates( - """ - The handle of the gate configurations to search for. - """ - handle: Handle - ): [GateSubject!]! -} - -""" -Represents information about the metafields associated to the specified resource. -""" -interface HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents whether the current object has the given tag. -""" -type HasTagResponse { - """ - Whether the current object has the tag. - """ - hasTag: Boolean! - - """ - The tag. - """ - tag: String! -} - -""" -The attributes associated with an HTTP request. -""" -input HttpRequest { - """ - The HTTP request body as a plain string. - Use this field when the body isn't in JSON format. - """ - body: String - - """ - The HTTP headers. - """ - headers: [HttpRequestHeader!]! - - """ - The HTTP request body as a JSON object. - Use this field when the body's in JSON format, to reduce function instruction consumption - and to ensure the body's formatted in logs. - Don't use this field together with the `body` field. If both are provided, then the `body` field - will take precedence. - If this field is specified and no `Content-Type` header is included, then the header will - automatically be set to `application/json`. - """ - jsonBody: JSON - - """ - The HTTP method. - """ - method: HttpRequestMethod! - - """ - Policy attached to the HTTP request. - """ - policy: HttpRequestPolicy! - - """ - The HTTP url (eg.: https://example.com). The scheme needs to be HTTPS. - """ - url: URL! -} - -""" -The attributes associated with an HTTP request header. -""" -input HttpRequestHeader { - """ - Header name. - """ - name: String! - - """ - Header value. - """ - value: String! -} - -""" -The HTTP request available methods. -""" -enum HttpRequestMethod { - """ - Http GET. - """ - GET - - """ - Http POST. - """ - POST -} - -""" -The attributes associated with an HTTP request policy. -""" -input HttpRequestPolicy { - """ - Read timeout in milliseconds. - """ - readTimeoutMs: Int! -} - -""" -The attributes associated with an HTTP response. -""" -type HttpResponse { - """ - The HTTP response body as a plain string. - Use this field when the body is not in JSON format. - """ - body: String - - """ - An HTTP header. - """ - header( - """ - A case-insensitive header name. - """ - name: String! - ): HttpResponseHeader - - """ - The HTTP headers. - """ - headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") - - """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. - Use this field when you expect the response to be JSON, or when you're dealing - with mixed response types, meaning both JSON and non-JSON. - Using this field reduces function instruction consumption and ensures that the data is formatted in logs. - To prevent increasing the function target input size unnecessarily, avoid querying - both `body` and `jsonBody` simultaneously. - """ - jsonBody: JSON - - """ - The HTTP status code. - """ - status: Int! -} - -""" -The attributes associated with an HTTP response header. -""" -type HttpResponseHeader { - """ - Header name. - """ - name: String! - - """ - Header value. - """ - value: String! -} - -""" -Represents a unique identifier, often used to refetch an object. -The ID type appears in a JSON response as a String, but it is not intended to be human-readable. - -Example value: `"gid://shopify/Product/10079785100"` -""" -scalar ID - -""" -The input object for the Function. -""" -type Input { - """ - The cart. - """ - cart: Cart! - - """ - The discount node executing the Function. - """ - discount: Discount! - - """ - Discount codes entered by the buyer as an array of strings, excluding gift cards. - Codes are not validated in any way other than gift card filtering. - """ - enteredDiscountCodes: [String!]! @restrictTarget(only: ["cart.lines.discounts.generate.fetch", "cart.delivery-options.discounts.generate.fetch"]) - - """ - The result of the fetch target. Refer to [network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) - for Shopify Functions. - """ - fetchResult: HttpResponse @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) - - """ - The localization of the Function execution context. - """ - localization: Localization! - - """ - The conversion rate between the shop's currency and the currency of the cart. - """ - presentmentCurrencyRate: Decimal! - - """ - Information about the shop. - """ - shop: Shop! - - """ - The discount code entered by the buyer that caused the Function to run. - This input is only available in the cart.lines.discounts.generate.run - and cart.delivery-options.discounts.generate.run extension targets. - """ - triggeringDiscountCode: String @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) -} - -""" -A [JSON](https://www.json.org/json-en.html) object. - -Example value: -`{ - "product": { - "id": "gid://shopify/Product/1346443542550", - "title": "White T-shirt", - "options": [{ - "name": "Size", - "values": ["M", "L"] - }] - } -}` -""" -scalar JSON - -""" -A language. -""" -type Language { - """ - The ISO code. - """ - isoCode: LanguageCode! -} - -""" -Language codes supported by Shopify. -""" -enum LanguageCode { - """ - Afrikaans. - """ - AF - - """ - Akan. - """ - AK - - """ - Amharic. - """ - AM - - """ - Arabic. - """ - AR - - """ - Assamese. - """ - AS - - """ - Azerbaijani. - """ - AZ - - """ - Belarusian. - """ - BE - - """ - Bulgarian. - """ - BG - - """ - Bambara. - """ - BM - - """ - Bangla. - """ - BN - - """ - Tibetan. - """ - BO - - """ - Breton. - """ - BR - - """ - Bosnian. - """ - BS - - """ - Catalan. - """ - CA - - """ - Chechen. - """ - CE - - """ - Central Kurdish. - """ - CKB - - """ - Czech. - """ - CS - - """ - Church Slavic. - """ - CU - - """ - Welsh. - """ - CY - - """ - Danish. - """ - DA - - """ - German. - """ - DE - - """ - Dzongkha. - """ - DZ - - """ - Ewe. - """ - EE - - """ - Greek. - """ - EL - - """ - English. - """ - EN - - """ - Esperanto. - """ - EO - - """ - Spanish. - """ - ES - - """ - Estonian. - """ - ET - - """ - Basque. - """ - EU - - """ - Persian. - """ - FA - - """ - Fulah. - """ - FF - - """ - Finnish. - """ - FI - - """ - Filipino. - """ - FIL - - """ - Faroese. - """ - FO - - """ - French. - """ - FR - - """ - Western Frisian. - """ - FY - - """ - Irish. - """ - GA - - """ - Scottish Gaelic. - """ - GD - - """ - Galician. - """ - GL - - """ - Gujarati. - """ - GU - - """ - Manx. - """ - GV - - """ - Hausa. - """ - HA - - """ - Hebrew. - """ - HE - - """ - Hindi. - """ - HI - - """ - Croatian. - """ - HR - - """ - Hungarian. - """ - HU - - """ - Armenian. - """ - HY - - """ - Interlingua. - """ - IA - - """ - Indonesian. - """ - ID - - """ - Igbo. - """ - IG - - """ - Sichuan Yi. - """ - II - - """ - Icelandic. - """ - IS - - """ - Italian. - """ - IT - - """ - Japanese. - """ - JA - - """ - Javanese. - """ - JV - - """ - Georgian. - """ - KA - - """ - Kikuyu. - """ - KI - - """ - Kazakh. - """ - KK - - """ - Kalaallisut. - """ - KL - - """ - Khmer. - """ - KM - - """ - Kannada. - """ - KN - - """ - Korean. - """ - KO - - """ - Kashmiri. - """ - KS - - """ - Kurdish. - """ - KU - - """ - Cornish. - """ - KW - - """ - Kyrgyz. - """ - KY - - """ - Luxembourgish. - """ - LB - - """ - Ganda. - """ - LG - - """ - Lingala. - """ - LN - - """ - Lao. - """ - LO - - """ - Lithuanian. - """ - LT - - """ - Luba-Katanga. - """ - LU - - """ - Latvian. - """ - LV - - """ - Malagasy. - """ - MG - - """ - Māori. - """ - MI - - """ - Macedonian. - """ - MK - - """ - Malayalam. - """ - ML - - """ - Mongolian. - """ - MN - - """ - Marathi. - """ - MR - - """ - Malay. - """ - MS - - """ - Maltese. - """ - MT - - """ - Burmese. - """ - MY - - """ - Norwegian (Bokmål). - """ - NB - - """ - North Ndebele. - """ - ND - - """ - Nepali. - """ - NE - - """ - Dutch. - """ - NL - - """ - Norwegian Nynorsk. - """ - NN - - """ - Norwegian. - """ - NO - - """ - Oromo. - """ - OM - - """ - Odia. - """ - OR - - """ - Ossetic. - """ - OS - - """ - Punjabi. - """ - PA - - """ - Polish. - """ - PL - - """ - Pashto. - """ - PS - - """ - Portuguese. - """ - PT - - """ - Portuguese (Brazil). - """ - PT_BR - - """ - Portuguese (Portugal). - """ - PT_PT - - """ - Quechua. - """ - QU - - """ - Romansh. - """ - RM - - """ - Rundi. - """ - RN - - """ - Romanian. - """ - RO - - """ - Russian. - """ - RU - - """ - Kinyarwanda. - """ - RW - - """ - Sanskrit. - """ - SA - - """ - Sardinian. - """ - SC - - """ - Sindhi. - """ - SD - - """ - Northern Sami. - """ - SE - - """ - Sango. - """ - SG - - """ - Sinhala. - """ - SI - - """ - Slovak. - """ - SK - - """ - Slovenian. - """ - SL - - """ - Shona. - """ - SN - - """ - Somali. - """ - SO - - """ - Albanian. - """ - SQ - - """ - Serbian. - """ - SR - - """ - Sundanese. - """ - SU - - """ - Swedish. - """ - SV - - """ - Swahili. - """ - SW - - """ - Tamil. - """ - TA - - """ - Telugu. - """ - TE - - """ - Tajik. - """ - TG - - """ - Thai. - """ - TH - - """ - Tigrinya. - """ - TI - - """ - Turkmen. - """ - TK - - """ - Tongan. - """ - TO - - """ - Turkish. - """ - TR - - """ - Tatar. - """ - TT - - """ - Uyghur. - """ - UG - - """ - Ukrainian. - """ - UK - - """ - Urdu. - """ - UR - - """ - Uzbek. - """ - UZ - - """ - Vietnamese. - """ - VI - - """ - Volapük. - """ - VO - - """ - Wolof. - """ - WO - - """ - Xhosa. - """ - XH - - """ - Yiddish. - """ - YI - - """ - Yoruba. - """ - YO - - """ - Chinese. - """ - ZH - - """ - Chinese (Simplified). - """ - ZH_CN - - """ - Chinese (Traditional). - """ - ZH_TW - - """ - Zulu. - """ - ZU -} - -""" -Represents limited information about the current time relative to the parent object. -""" -type LocalTime { - """ - The current date relative to the parent object. - """ - date: Date! - - """ - Returns true if the current date and time is at or past the given date and time, and false otherwise. - """ - dateTimeAfter( - """ - The date and time to compare against, assumed to be in the timezone of the parent object. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is before the given date and time, and false otherwise. - """ - dateTimeBefore( - """ - The date and time to compare against, assumed to be in the timezone of the parent timezone. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is between the two given date and times, and false otherwise. - """ - dateTimeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endDateTime: DateTimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startDateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeAfter( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeBefore( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is between the two given times, and false otherwise. - """ - timeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endTime: TimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startTime: TimeWithoutTimezone! - ): Boolean! -} - -""" -Information about the localized experiences configured for the shop. -""" -type Localization { - """ - The country of the active localized experience. - """ - country: Country! - - """ - The language of the active localized experience. - """ - language: Language! - - """ - The market of the active localized experience. - """ - market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") -} - -""" -Represents the value captured by a localized field. Localized fields are -additional fields required by certain countries on international orders. For -example, some countries require additional fields for customs information or tax -identification numbers. -""" -type LocalizedField { - """ - The key of the localized field. - """ - key: LocalizedFieldKey! - - """ - The title of the localized field. - """ - title: String! - - """ - The value of the localized field. - """ - value: String -} - -""" -Unique key identifying localized fields. -""" -enum LocalizedFieldKey { - """ - Localized field key 'shipping_credential_br' for country Brazil. - """ - SHIPPING_CREDENTIAL_BR - - """ - Localized field key 'shipping_credential_cl' for country Chile. - """ - SHIPPING_CREDENTIAL_CL - - """ - Localized field key 'shipping_credential_cn' for country China. - """ - SHIPPING_CREDENTIAL_CN - - """ - Localized field key 'shipping_credential_co' for country Colombia. - """ - SHIPPING_CREDENTIAL_CO - - """ - Localized field key 'shipping_credential_cr' for country Costa Rica. - """ - SHIPPING_CREDENTIAL_CR - - """ - Localized field key 'shipping_credential_ec' for country Ecuador. - """ - SHIPPING_CREDENTIAL_EC - - """ - Localized field key 'shipping_credential_es' for country Spain. - """ - SHIPPING_CREDENTIAL_ES - - """ - Localized field key 'shipping_credential_gt' for country Guatemala. - """ - SHIPPING_CREDENTIAL_GT - - """ - Localized field key 'shipping_credential_id' for country Indonesia. - """ - SHIPPING_CREDENTIAL_ID - - """ - Localized field key 'shipping_credential_kr' for country South Korea. - """ - SHIPPING_CREDENTIAL_KR - - """ - Localized field key 'shipping_credential_mx' for country Mexico. - """ - SHIPPING_CREDENTIAL_MX - - """ - Localized field key 'shipping_credential_my' for country Malaysia. - """ - SHIPPING_CREDENTIAL_MY - - """ - Localized field key 'shipping_credential_pe' for country Peru. - """ - SHIPPING_CREDENTIAL_PE - - """ - Localized field key 'shipping_credential_pt' for country Portugal. - """ - SHIPPING_CREDENTIAL_PT - - """ - Localized field key 'shipping_credential_py' for country Paraguay. - """ - SHIPPING_CREDENTIAL_PY - - """ - Localized field key 'shipping_credential_tr' for country Turkey. - """ - SHIPPING_CREDENTIAL_TR - - """ - Localized field key 'shipping_credential_tw' for country Taiwan. - """ - SHIPPING_CREDENTIAL_TW - - """ - Localized field key 'shipping_credential_type_co' for country Colombia. - """ - SHIPPING_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_br' for country Brazil. - """ - TAX_CREDENTIAL_BR - - """ - Localized field key 'tax_credential_cl' for country Chile. - """ - TAX_CREDENTIAL_CL - - """ - Localized field key 'tax_credential_co' for country Colombia. - """ - TAX_CREDENTIAL_CO - - """ - Localized field key 'tax_credential_cr' for country Costa Rica. - """ - TAX_CREDENTIAL_CR - - """ - Localized field key 'tax_credential_ec' for country Ecuador. - """ - TAX_CREDENTIAL_EC - - """ - Localized field key 'tax_credential_es' for country Spain. - """ - TAX_CREDENTIAL_ES - - """ - Localized field key 'tax_credential_gt' for country Guatemala. - """ - TAX_CREDENTIAL_GT - - """ - Localized field key 'tax_credential_id' for country Indonesia. - """ - TAX_CREDENTIAL_ID - - """ - Localized field key 'tax_credential_it' for country Italy. - """ - TAX_CREDENTIAL_IT - - """ - Localized field key 'tax_credential_mx' for country Mexico. - """ - TAX_CREDENTIAL_MX - - """ - Localized field key 'tax_credential_my' for country Malaysia. - """ - TAX_CREDENTIAL_MY - - """ - Localized field key 'tax_credential_pe' for country Peru. - """ - TAX_CREDENTIAL_PE - - """ - Localized field key 'tax_credential_pt' for country Portugal. - """ - TAX_CREDENTIAL_PT - - """ - Localized field key 'tax_credential_py' for country Paraguay. - """ - TAX_CREDENTIAL_PY - - """ - Localized field key 'tax_credential_tr' for country Turkey. - """ - TAX_CREDENTIAL_TR - - """ - Localized field key 'tax_credential_type_co' for country Colombia. - """ - TAX_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_type_mx' for country Mexico. - """ - TAX_CREDENTIAL_TYPE_MX - - """ - Localized field key 'tax_credential_use_mx' for country Mexico. - """ - TAX_CREDENTIAL_USE_MX - - """ - Localized field key 'tax_email_it' for country Italy. - """ - TAX_EMAIL_IT -} - -""" -Represents a mailing address. -""" -type MailingAddress { - """ - The first line of the address. Typically the street address or PO Box number. - """ - address1: String - - """ - The second line of the address. Typically the number of the apartment, suite, or unit. - """ - address2: String - - """ - The name of the city, district, village, or town. - """ - city: String - - """ - The name of the customer's company or organization. - """ - company: String - - """ - The two-letter code for the country of the address. For example, US. - """ - countryCode: CountryCode - - """ - The first name of the customer. - """ - firstName: String - - """ - The last name of the customer. - """ - lastName: String - - """ - The approximate latitude of the address. - """ - latitude: Float - - """ - The approximate longitude of the address. - """ - longitude: Float - - """ - The market of the address. - """ - market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") - - """ - The full name of the customer, based on firstName and lastName. - """ - name: String - - """ - A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. - """ - phone: String - - """ - The alphanumeric code for the region. For example, ON. - """ - provinceCode: String - - """ - The zip or postal code of the address. - """ - zip: String -} - -""" -A market is a group of one or more regions that you want to target for international sales. -By creating a market, you can configure a distinct, localized shopping experience for -customers from a specific area of the world. For example, you can -[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), -[configure international pricing](https://shopify.dev/api/examples/product-price-lists), -or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). -""" -type Market implements HasMetafields { - """ - A human-readable unique string for the market automatically generated from its title. - """ - handle: Handle! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - A geographic region which comprises a market. - """ - regions: [MarketRegion!]! -} - -""" -Represents a region. -""" -interface MarketRegion { - """ - The name of the region in the language of the current localization. - """ - name: String -} - -""" -A country which comprises a market. -""" -type MarketRegionCountry implements MarketRegion { - """ - The two-letter code for the country. - """ - code: CountryCode! - - """ - The country name in the language of the current localization. - """ - name: String! -} - -""" -The merchandise to be purchased at checkout. -""" -union Merchandise = CustomProduct | ProductVariant - -""" -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). -""" -type Metafield { - """ - The data stored in the metafield in JSON format. - """ - jsonValue: JSON! - - """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). - """ - type: String! - - """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. - """ - value: String! -} - -""" -A monetary value with currency. -""" -type MoneyV2 { - """ - Decimal money amount. - """ - amount: Decimal! - - """ - Currency of the money. - """ - currencyCode: CurrencyCode! -} - -""" -The root mutation for the API. -""" -type MutationRoot { - """ - Handles the Function result for the cart.delivery-options.discounts.generate.fetch target. - """ - cartDeliveryOptionsDiscountsGenerateFetch( - """ - The result of the Function. - """ - result: FunctionDeliveryFetchResult! - ): Void! - - """ - Handles the Function result for the cart.delivery-options.discounts.generate.run target. - """ - cartDeliveryOptionsDiscountsGenerateRun( - """ - The result of the Function. - """ - result: FunctionDeliveryRunResult! - ): Void! - - """ - Handles the Function result for the cart.lines.discounts.generate.fetch target. - """ - cartLinesDiscountsGenerateFetch( - """ - The result of the Function. - """ - result: FunctionCartFetchResult! - ): Void! - - """ - Handles the Function result for the cart.lines.discounts.generate.run target. - """ - cartLinesDiscountsGenerateRun( - """ - The result of the Function. - """ - result: FunctionCartRunResult! - ): Void! -} - -""" -The order discount candidate to be applied. -""" -input OrderDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The conditions that must be satisfied to apply the order discount candidate. - """ - conditions: [Condition!] - - """ - The discount message. - """ - message: String - - """ - The targets of the order discount candidate. - """ - targets: [OrderDiscountCandidateTarget!]! - - """ - The value of the order discount candidate. - """ - value: OrderDiscountCandidateValue! -} - -""" -A target of a order discount candidate. -""" -input OrderDiscountCandidateTarget @oneOf { - """ - If used, the discount targets the entire order subtotal after product discounts are applied. - """ - orderSubtotal: OrderSubtotalTarget -} - -""" -The order discount candidate value. -""" -input OrderDiscountCandidateValue @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of order discount candidates. -""" -enum OrderDiscountSelectionStrategy { - """ - Only apply the first order discount candidate with conditions that are satisfied. - """ - FIRST - - """ - Only apply the order discount candidate that offers the maximum reduction. - """ - MAXIMUM -} - -""" -A group of order discounts that share a selection strategy. -""" -input OrderDiscounts { - """ - The list of order discount candidates to be applied. - """ - candidates: [OrderDiscountCandidate!]! - - """ - The strategy that's applied to the list of discounts. - """ - selectionStrategy: OrderDiscountSelectionStrategy! -} - -""" -The condition for checking the minimum subtotal amount of the order. -""" -input OrderMinimumSubtotal { - """ - Cart line IDs with a merchandise line price that's excluded to calculate the minimum subtotal amount of the order. - """ - excludedCartLineIds: [ID!]! - - """ - The minimum subtotal amount of the order. - """ - minimumAmount: Decimal! -} - -""" -If used, the discount targets the entire order subtotal after product discounts are applied. -""" -input OrderSubtotalTarget { - """ - The list of excluded cart line IDs. These cart lines are excluded from the order - subtotal calculation when calculating the maximum value of the discount. - """ - excludedCartLineIds: [ID!]! -} - -""" -A percentage value. -""" -input Percentage { - """ - The percentage value. - - The value is validated against: >= 0 and <= 100. - """ - value: Decimal! -} - -""" -Represents a product. -""" -type Product implements HasGates & HasMetafields { - """ - Returns active gate subjects bound to the resource. - """ - gates( - """ - The handle of the gate configurations to search for. - """ - handle: Handle - ): [GateSubject!]! - - """ - A unique human-friendly string of the product's title. - """ - handle: Handle! - - """ - Whether the product has any of the given tags. - """ - hasAnyTag( - """ - The tags to check. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the product has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Whether the product is in any of the given collections. - """ - inAnyCollection( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): Boolean! - - """ - Whether the product is in the given collections. - """ - inCollections( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): [CollectionMembership!]! - - """ - Whether the product is a gift card. - """ - isGiftCard: Boolean! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product type specified by the merchant. - """ - productType: String - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The name of the product's vendor. - """ - vendor: String -} - -""" -The product discount candidate to be applied. -""" -input ProductDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The discount message. - """ - message: String - - """ - The targets of the product discount candidate. - """ - targets: [ProductDiscountCandidateTarget!]! - - """ - The value of the product discount candidate. - """ - value: ProductDiscountCandidateValue! -} - -""" -A product discount candidate fixed amount value. -""" -input ProductDiscountCandidateFixedAmount { - """ - The fixed amount value of the product discount candidate, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! - - """ - Whether to apply the value to each entitled item. - - The default value is `false`, which causes the value to be applied once across the entitled items. - When the value is `true`, the value will be applied to each of the entitled items. - """ - appliesToEachItem: Boolean = false -} - -""" -A target of a product discount candidate, which determines which cart line(s) the discount will affect. - -Multiple targets with the same type and ID are the same as a single target of that type and ID with their -quantities added together, or `null` if any of those targets have a quantity of `null`. - -See the [Discounts API reference](https://shopify.dev/docs/api/functions/reference/product-discounts/graphql#functionrunresult) for examples. -""" -input ProductDiscountCandidateTarget @oneOf { - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. - """ - cartLine: CartLineTarget -} - -""" -The value of the product discount candidate. -""" -input ProductDiscountCandidateValue @oneOf { - """ - A product discount candidate fixed amount value. - """ - fixedAmount: ProductDiscountCandidateFixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of product discount candidates. -""" -enum ProductDiscountSelectionStrategy { - """ - Apply all product discount candidates with conditions that are satisfied. This - does not override discount combination or stacking rules. - """ - ALL - - """ - Only apply the first product discount candidate with conditions that are satisfied. - """ - FIRST - - """ - Only apply the product discount candidate that offers the maximum reduction. - """ - MAXIMUM -} - -""" -A group of product discounts that share a selection strategy. -""" -input ProductDiscounts { - """ - The list of product discount candidates to be applied. - """ - candidates: [ProductDiscountCandidate!]! - - """ - The strategy that's applied to the list of product discount candidates. - """ - selectionStrategy: ProductDiscountSelectionStrategy! -} - -""" -Represents a product variant. -""" -type ProductVariant implements HasMetafields { - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product that this variant belongs to. - """ - product: Product! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. - """ - sku: String - - """ - The localized title of the product variant in the customer’s locale. - """ - title: String - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type PurchasingCompany { - """ - The company associated to the order or draft order. - """ - company: Company! - - """ - The company contact associated to the order or draft order. - """ - contact: CompanyContact - - """ - The company location associated to the order or draft order. - """ - location: CompanyLocation! -} - -""" -Represents how products and variants can be sold and purchased. -""" -type SellingPlan implements HasMetafields { - """ - The description of the selling plan. - """ - description: String - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. - """ - name: String! - - """ - Whether purchasing the selling plan will result in multiple deliveries. - """ - recurringDeliveries: Boolean! -} - -""" -Represents an association between a variant and a selling plan. Selling plan -allocations describe the options offered for each variant, and the price of the -variant when purchased with a selling plan. -""" -type SellingPlanAllocation { - """ - A list of price adjustments, with a maximum of two. When there are two, the - first price adjustment goes into effect at the time of purchase, while the - second one starts after a certain number of orders. A price adjustment - represents how a selling plan affects pricing when a variant is purchased with - a selling plan. Prices display in the customer's currency if the shop is - configured for it. - """ - priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! - - """ - A representation of how products and variants can be sold and purchased. For - example, an individual selling plan could be '6 weeks of prepaid granola, - delivered weekly'. - """ - sellingPlan: SellingPlan! -} - -""" -The resulting prices for variants when they're purchased with a specific selling plan. -""" -type SellingPlanAllocationPriceAdjustment { - """ - The effective price for a single delivery. For example, for a prepaid - subscription plan that includes 6 deliveries at the price of $48.00, the per - delivery price is $8.00. - """ - perDeliveryPrice: MoneyV2! - - """ - The price of the variant when it's purchased with a selling plan For example, - for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, - where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. - """ - price: MoneyV2! -} - -""" -Information about the shop. -""" -type Shop implements HasMetafields { - """ - Information about the current time relative to the shop's timezone setting. - """ - localTime: LocalTime! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the time but not the date or timezone which is determined from context. -For example, "05:43:21". -""" -scalar TimeWithoutTimezone - -""" -Represents an [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) and -[RFC 3987](https://datatracker.ietf.org/doc/html/rfc3987)-compliant URI string. - -For example, `"https://example.myshopify.com"` is a valid URL. It includes a scheme (`https`) and a host -(`example.myshopify.com`). -""" -scalar URL - -""" -A discount code that corresponds to a valid external discount. -This can only be used by Functions with network access. -""" -input ValidDiscountCode { - """ - The discount code. - """ - code: String! -} - -""" -A list of valid discount codes that correspond to external discounts. This can -only be used by Functions with network access. -""" -input ValidDiscountCodes { - """ - The list of valid discount codes. - """ - codes: [ValidDiscountCode!]! -} - -""" -A void type that can be used to return a null value from a mutation. -""" -scalar Void - -""" -Units of measurement for weight. -""" -enum WeightUnit { - """ - Metric system unit of mass. - """ - GRAMS - - """ - 1 kilogram equals 1000 grams. - """ - KILOGRAMS - - """ - Imperial system unit of mass. - """ - OUNCES - - """ - 1 pound equals 16 ounces. - """ - POUNDS -} diff --git a/discounts/javascript/network/default/shopify.extension.toml.liquid b/discounts/javascript/network/default/shopify.extension.toml.liquid deleted file mode 100644 index afd78e93..00000000 --- a/discounts/javascript/network/default/shopify.extension.toml.liquid +++ /dev/null @@ -1,32 +0,0 @@ -api_version = "2025-04" - -[[extensions]] -name = "t:name" -handle = "{{handle}}" -type = "function" -{% if uid %}uid = "{{ uid }}"{% endif %} -description = "t:description" - - [[extensions.targeting]] - target = "cart.lines.discounts.generate.run" - input_query = "src/generate_cart_run.graphql" - export = "generate-cart-run" - - [[extensions.targeting]] - target = "cart.delivery-options.discounts.generate.run" - input_query = "src/generate_delivery_run.graphql" - export = "generate-delivery-run" - - [[extensions.targeting]] - target = "cart.lines.discounts.generate.fetch" - input_query = "src/generate_cart_fetch.graphql" - export = "generate-cart-fetch" - - [[extensions.targeting]] - target = "cart.delivery-options.discounts.generate.fetch" - input_query = "src/generate_delivery_fetch.graphql" - export = "generate-delivery-fetch" - - [extensions.build] - command = "" - path = "dist/function.wasm" diff --git a/discounts/javascript/network/default/src/generate_cart_fetch.graphql.liquid b/discounts/javascript/network/default/src/generate_cart_fetch.graphql.liquid deleted file mode 100644 index e44ae593..00000000 --- a/discounts/javascript/network/default/src/generate_cart_fetch.graphql.liquid +++ /dev/null @@ -1,3 +0,0 @@ -query InputCartFetch { - enteredDiscountCodes -} diff --git a/discounts/javascript/network/default/src/generate_cart_fetch.liquid b/discounts/javascript/network/default/src/generate_cart_fetch.liquid deleted file mode 100644 index e9871f04..00000000 --- a/discounts/javascript/network/default/src/generate_cart_fetch.liquid +++ /dev/null @@ -1,65 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check - -import {HttpRequestMethod} from '../generated/api'; - -/** - * @typedef {import("../generated/api").Input} InputCartFetch - * @typedef {import("../generated/api").CartLinesDiscountsGenerateFetchResult} CartLinesDiscountsGenerateFetchResult - */ -/** - * Generates a network request to fetch cart discount information - * @param {InputCartFetch} input - The cart fetch input data - * @returns {CartLinesDiscountsGenerateFetchResult} - The function result with network request configuration - */ -export function generateCartFetch(input) { - const { enteredDiscountCodes } = input; - const jsonBody = { enteredDiscountCodes }; - const request = { - headers: [ - { - name: 'accept', - value: 'application/json', - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: '', - body: JSON.stringify(jsonBody), - jsonBody, - }; - return { request }; -} -{%- elsif flavor contains "typescript" -%} -import { - HttpRequestMethod, - InputCartFetch, - CartLinesDiscountsGenerateFetchResult, -} from '../generated/api'; - -export function generateCartFetch( - input: InputCartFetch, -): CartLinesDiscountsGenerateFetchResult { - const {enteredDiscountCodes} = input; - const jsonBody = {enteredDiscountCodes}; - const request = { - headers: [ - { - name: 'accept', - value: 'application/json', - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: '', - body: JSON.stringify(jsonBody), - jsonBody, - }; - - return {request}; -} -{%- endif -%} diff --git a/discounts/javascript/network/default/src/generate_cart_run.graphql.liquid b/discounts/javascript/network/default/src/generate_cart_run.graphql.liquid deleted file mode 100644 index 2ba17002..00000000 --- a/discounts/javascript/network/default/src/generate_cart_run.graphql.liquid +++ /dev/null @@ -1,6 +0,0 @@ -query InputCartRun { - fetchResult { - body - } -} - diff --git a/discounts/javascript/network/default/src/generate_cart_run.liquid b/discounts/javascript/network/default/src/generate_cart_run.liquid deleted file mode 100644 index 64080bd2..00000000 --- a/discounts/javascript/network/default/src/generate_cart_run.liquid +++ /dev/null @@ -1,37 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check -/** - * @typedef {import("../generated/api").Input} InputCartRun - * @typedef {import("../generated/api").CartLinesDiscountsGenerateRunResult} CartLinesDiscountsGenerateRunResult - */ -/** - * Processes the fetched cart discount data and generates operations - * @param {InputCartRun} input - The cart run input data including fetch results - * @returns {CartLinesDiscountsGenerateRunResult} - The function result with discount operations - */ -export function generateCartRun(input) { - const { fetchResult } = input; - const body = fetchResult?.body; - if (!body) { - throw new Error('Missing response body'); - } - // Parse the response body and extract the operations - const { operations } = JSON.parse(body); - return { operations }; -} -{%- elsif flavor contains "typescript" -%} -import {InputCartRun, CartLinesDiscountsGenerateRunResult} from '../generated/api'; - -export function generateCartRun(input: InputCartRun): CartLinesDiscountsGenerateRunResult { - const {fetchResult} = input; - const body = fetchResult?.body; - - if (!body) { - throw new Error('Missing response body'); - } - - // Parse the response body and extract the operations - const {operations} = JSON.parse(body); - return {operations}; -} -{%- endif -%} diff --git a/discounts/javascript/network/default/src/generate_delivery_fetch.graphql.liquid b/discounts/javascript/network/default/src/generate_delivery_fetch.graphql.liquid deleted file mode 100644 index 005de91b..00000000 --- a/discounts/javascript/network/default/src/generate_delivery_fetch.graphql.liquid +++ /dev/null @@ -1,3 +0,0 @@ -query InputDeliveryFetch { - enteredDiscountCodes -} diff --git a/discounts/javascript/network/default/src/generate_delivery_fetch.liquid b/discounts/javascript/network/default/src/generate_delivery_fetch.liquid deleted file mode 100644 index c568735d..00000000 --- a/discounts/javascript/network/default/src/generate_delivery_fetch.liquid +++ /dev/null @@ -1,64 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check -import {HttpRequestMethod} from '../generated/api'; - -/** - * @typedef {import("../generated/api").Input} InputDeliveryFetch - * @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateFetchResult} CartDeliveryOptionsDiscountsGenerateFetchResult - */ -/** - * Generates a network request to fetch delivery discount information - * @param {InputDeliveryFetch} input - The delivery fetch input data - * @returns {CartDeliveryOptionsDiscountsGenerateFetchResult} - The function result with network request configuration - */ -export function generateDeliveryFetch(input) { - const { enteredDiscountCodes } = input; - const jsonBody = { enteredDiscountCodes }; - const request = { - headers: [ - { - name: 'accept', - value: 'application/json', - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: '', - body: JSON.stringify(jsonBody), - jsonBody, - }; - return { request }; -} -{%- elsif flavor contains "typescript" -%} -import { - HttpRequestMethod, - InputDeliveryFetch, - CartDeliveryOptionsDiscountsGenerateFetchResult, -} from '../generated/api'; -export function generateDeliveryFetch( - input: InputDeliveryFetch, -): CartDeliveryOptionsDiscountsGenerateFetchResult { - const {enteredDiscountCodes} = input; - const jsonBody = {enteredDiscountCodes}; - - const request = { - headers: [ - { - name: 'accept', - value: 'application/json', - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: '', - body: JSON.stringify(jsonBody), - jsonBody, - }; - - return {request}; -} -{%- endif -%} diff --git a/discounts/javascript/network/default/src/generate_delivery_run.graphql.liquid b/discounts/javascript/network/default/src/generate_delivery_run.graphql.liquid deleted file mode 100644 index 73503a1b..00000000 --- a/discounts/javascript/network/default/src/generate_delivery_run.graphql.liquid +++ /dev/null @@ -1,11 +0,0 @@ -query InputDeliveryRun { - fetchResult { - body - status - } - cart { - deliveryGroups { - id - } - } -} diff --git a/discounts/javascript/network/default/src/generate_delivery_run.liquid b/discounts/javascript/network/default/src/generate_delivery_run.liquid deleted file mode 100644 index f2ee7318..00000000 --- a/discounts/javascript/network/default/src/generate_delivery_run.liquid +++ /dev/null @@ -1,39 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check -/** - * @typedef {import("../generated/api").Input} InputDeliveryRun - * @typedef {import("../generated/api").CartDeliveryOptionsDiscountsGenerateRunResult} CartDeliveryOptionsDiscountsGenerateRunResult - */ -/** - * Processes the fetched delivery discount data and generates operations - * @param {InputDeliveryRun} input - The delivery run input data including fetch results - * @returns {CartDeliveryOptionsDiscountsGenerateRunResult} - The function result with discount operations - */ -export function generateDeliveryRun(input) { - const { fetchResult } = input; - const body = fetchResult?.body; - if (!body) { - throw new Error('Missing response body'); - } - // Parse the response body and extract the operations - const { operations } = JSON.parse(body); - return { operations }; -} -{%- elsif flavor contains "typescript" -%} -import {InputDeliveryRun, CartDeliveryOptionsDiscountsGenerateRunResult} from '../generated/api'; - -export function generateDeliveryRun( - input: InputDeliveryRun, -): CartDeliveryOptionsDiscountsGenerateRunResult { - const {fetchResult} = input; - const body = fetchResult?.body; - - if (!body) { - throw new Error('Missing response body'); - } - - // Parse the response body and extract the operations - const {operations} = JSON.parse(body); - return {operations}; -} -{%- endif -%} diff --git a/discounts/javascript/network/default/src/generate_discount_default.test.liquid b/discounts/javascript/network/default/src/generate_discount_default.test.liquid deleted file mode 100644 index eda1cf66..00000000 --- a/discounts/javascript/network/default/src/generate_discount_default.test.liquid +++ /dev/null @@ -1,8 +0,0 @@ -import { describe, it, expect } from 'vitest'; - - -describe('generate_discount_default', () => { - it('passes the test', () => { - expect(true).toBe(true); - }); -}); \ No newline at end of file diff --git a/discounts/javascript/network/default/src/index.liquid b/discounts/javascript/network/default/src/index.liquid deleted file mode 100644 index 1e8b90b3..00000000 --- a/discounts/javascript/network/default/src/index.liquid +++ /dev/null @@ -1,4 +0,0 @@ -export * from './generate_cart_run'; -export * from './generate_delivery_run'; -export * from './generate_cart_fetch'; -export * from './generate_delivery_fetch'; diff --git a/discounts/javascript/network/default/src/network.test.liquid b/discounts/javascript/network/default/src/network.test.liquid deleted file mode 100644 index e04c682c..00000000 --- a/discounts/javascript/network/default/src/network.test.liquid +++ /dev/null @@ -1,167 +0,0 @@ -import { describe, it, expect } from "vitest"; - -import { generateCartFetch } from "./generate_cart_fetch"; -import { generateDeliveryFetch } from "./generate_delivery_fetch"; -import { generateCartRun } from "./generate_cart_run"; -import { - HttpRequestMethod, - OrderDiscountSelectionStrategy, - ProductDiscountSelectionStrategy, - DeliveryDiscountSelectionStrategy, -} from "../generated/api"; - -describe("discount", () => { - it("cart.lines.discounts.generate.fetch returns a fetch request", () => { - const input = { - enteredDiscountCodes: ["10% OFF ORDER", "20% OFF PRODUCT"], - }; - - const result = generateCartFetch(input); - - expect(result.request).toMatchObject({ - headers: [ - { - name: "accept", - value: "application/json", - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: "", - body: JSON.stringify(input), - jsonBody: input, - }); - }); - - it("cart.delivery-options.discounts.generate.fetch returns a fetch request", () => { - const input = { - enteredDiscountCodes: ["FREE_DELIVERY"], - }; - - const result = generateDeliveryFetch(input); - - expect(result.request).toMatchObject({ - headers: [ - { - name: "accept", - value: "application/json", - }, - ], - method: HttpRequestMethod.Post, - policy: { - readTimeoutMs: 2000, - }, - url: "", - body: JSON.stringify(input), - jsonBody: input, - }); - }); - - it("cart.lines.discounts.generate.run returns a list of operations", () => { - const operations = [ - { - enteredDiscountCodesAccept: { - codes: ["10% OFF ORDER", "20% OFF PRODUCT"], - }, - }, - { - orderDiscountsAdd: { - candidates: [ - { - message: "10% OFF ORDER", - targets: [ - { - orderSubtotal: { - excludedCartLineIds: [], - }, - }, - ], - value: { - percentage: { - value: 10, - }, - }, - }, - ], - selectionStrategy: OrderDiscountSelectionStrategy.First, - }, - }, - { - productDiscountsAdd: { - candidates: [ - { - message: "20% OFF PRODUCT", - targets: [ - { - cartLine: { - id: "gid://shopify/CartLine/0", - }, - }, - ], - value: { - percentage: { - value: 20, - }, - }, - }, - ], - selectionStrategy: ProductDiscountSelectionStrategy.First, - }, - }, - ]; - - const input = { - fetchResult: { - body: JSON.stringify({ operations }), - }, - }; - - const result = generateCartRun(input); - - expect(result.operations).toMatchObject(operations); - }); - - it("cart.delivery-options.discounts.generate.run returns a list of operations", () => { - const operations = [ - { - enteredDiscountCodesAccept: { - codes: ["FREE_DELIVERY"], - }, - }, - { - deliveryDiscountsAdd: { - candidates: [ - { - message: "FREE DELIVERY", - targets: [ - { - deliveryGroup: { - id: "gid://shopify/DeliveryGroup/0", - }, - }, - ], - value: { - percentage: { - value: 100, - }, - }, - }, - ], - selectionStrategy: DeliveryDiscountSelectionStrategy.All, - }, - }, - ]; - - const input = { - fetchResult: { - body: JSON.stringify({ operations }), - }, - }; - - const result = generateCartRun(input); - - expect(result.operations).toMatchObject(operations); - }); -}); diff --git a/discounts/javascript/network/default/vite.config.js b/discounts/javascript/network/default/vite.config.js deleted file mode 100644 index 210c90d4..00000000 --- a/discounts/javascript/network/default/vite.config.js +++ /dev/null @@ -1 +0,0 @@ -// Prevents inheritance from parent Remix project diff --git a/discounts/rust/network/default/.gitignore b/discounts/rust/network/default/.gitignore deleted file mode 100644 index 96ef6c0b..00000000 --- a/discounts/rust/network/default/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -/target -Cargo.lock diff --git a/discounts/rust/network/default/Cargo.toml.liquid b/discounts/rust/network/default/Cargo.toml.liquid deleted file mode 100644 index 72bdfcd7..00000000 --- a/discounts/rust/network/default/Cargo.toml.liquid +++ /dev/null @@ -1,18 +0,0 @@ -[package] -name = "{{handle | replace: " ", "-" | downcase}}" -version = "1.0.0" -edition = "2021" - -[dependencies] -serde_json = "1.0" -shopify_function = "0.8.1" -graphql_client = "0.14.0" - - [dependencies.serde] - version = "1.0.13" - features = [ "derive" ] - -[profile.release] -lto = true -opt-level = "z" -strip = true diff --git a/discounts/rust/network/default/README.md b/discounts/rust/network/default/README.md deleted file mode 100644 index 574afb9c..00000000 --- a/discounts/rust/network/default/README.md +++ /dev/null @@ -1,16 +0,0 @@ -# Shopify Function development with Rust - -## Dependencies - -- [Install Rust](https://www.rust-lang.org/tools/install) - - On Windows, Rust requires the [Microsoft C++ Build Tools](https://docs.microsoft.com/en-us/windows/dev-environment/rust/setup). Be sure to select the _Desktop development with C++_ workload when installing them. - -## Building the function - -You can build this individual function using `cargo build`. - -```shell -cargo build --target=wasm32-wasip1 --release -``` - -The Shopify CLI `build` command will also execute this, based on the configuration in `shopify.extension.toml`. diff --git a/discounts/rust/network/default/schema.graphql b/discounts/rust/network/default/schema.graphql deleted file mode 100644 index 524ae957..00000000 --- a/discounts/rust/network/default/schema.graphql +++ /dev/null @@ -1,5170 +0,0 @@ -schema { - query: Input - mutation: MutationRoot -} - -""" -Only allow the field to be queried when targeting one of the specified targets. -""" -directive @restrictTarget(only: [String!]!) on FIELD_DEFINITION - -""" -Scale the Functions resource limits based on the field's length. -""" -directive @scaleLimits(rate: Float!) on FIELD_DEFINITION - -""" -Requires that exactly one field must be supplied and that field must not be `null`. -""" -directive @oneOf on INPUT_OBJECT - -""" -A discount code that is associated with a discount candidate. -""" -input AssociatedDiscountCode { - """ - The discount code. - """ - code: String! -} - -""" -Represents a generic custom attribute, such as whether an order is a customer's first. -""" -type Attribute { - """ - The key or name of the attribute. For example, `"customersFirstOrder"`. - """ - key: String! - - """ - The value of the attribute. For example, `"true"`. - """ - value: String -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type BuyerIdentity { - """ - The customer associated with the cart. - """ - customer: Customer - - """ - The email address of the buyer that's interacting with the cart. - """ - email: String - - """ - Whether the buyer authenticated with a customer account. - """ - isAuthenticated: Boolean! - - """ - The phone number of the buyer that's interacting with the cart. - """ - phone: String - - """ - The purchasing company associated with the cart. - """ - purchasingCompany: PurchasingCompany -} - -""" -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. -""" -type Cart { - """ - The attributes associated with the cart. Attributes are represented as key-value pairs. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - Information about the buyer that is interacting with the cart. - """ - buyerIdentity: BuyerIdentity - - """ - The costs that the buyer will pay at checkout. - """ - cost: CartCost! - - """ - A list of lines containing information about the items that can be delivered. - """ - deliverableLines: [DeliverableCartLine!]! - - """ - The delivery groups available for the cart based on the buyer's shipping address. - """ - deliveryGroups: [CartDeliveryGroup!]! - - """ - A list of lines containing information about the items the customer intends to purchase. - """ - lines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The localized fields available for the cart. - """ - localizedFields( - """ - The keys of the localized fields to retrieve. - """ - keys: [LocalizedFieldKey!]! = [] - ): [LocalizedField!]! -} - -""" -The cost that the buyer will pay at checkout. -""" -type CartCost { - """ - The amount, before taxes and discounts, for the customer to pay. - """ - subtotalAmount: MoneyV2! - - """ - The total amount for the customer to pay. - """ - totalAmount: MoneyV2! - - """ - The duty amount for the customer to pay at checkout. - """ - totalDutyAmount: MoneyV2 - - """ - The tax amount for the customer to pay at checkout. - """ - totalTaxAmount: MoneyV2 -} - -""" -Information about the options available for one or more line items to be delivered to a specific address. -""" -type CartDeliveryGroup { - """ - A list of cart lines for the delivery group. - """ - cartLines: [CartLine!]! @scaleLimits(rate: 0.005) - - """ - The destination address for the delivery group. - """ - deliveryAddress: MailingAddress - - """ - The delivery options available for the delivery group. - """ - deliveryOptions: [CartDeliveryOption!]! - - """ - Unique identifier for the delivery group. - """ - id: ID! - - """ - Information about the delivery option the buyer has selected. - """ - selectedDeliveryOption: CartDeliveryOption -} - -""" -Information about a delivery option. -""" -type CartDeliveryOption { - """ - The code of the delivery option. - """ - code: String - - """ - The cost for the delivery option. - """ - cost: MoneyV2! - - """ - The method for the delivery option. - """ - deliveryMethodType: DeliveryMethod! - - """ - The description of the delivery option. - """ - description: String - - """ - The unique identifier of the delivery option. - """ - handle: Handle! - - """ - The title of the delivery option. - """ - title: String -} - -""" -The cart.delivery-options.discounts.generate.fetch target result. Refer to -[network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. -""" -input CartDeliveryOptionsDiscountsGenerateFetchResult { - """ - The http request. - """ - request: HttpRequest -} - -""" -The cart.delivery-options.discounts.generate.run target result. -""" -input CartDeliveryOptionsDiscountsGenerateRunResult { - """ - The list of operations to apply discounts to the delivery lines. - """ - operations: [DeliveryOperation!]! -} - -""" -Represents information about the merchandise in the cart. -""" -type CartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The cost of the merchandise line that the buyer will pay at checkout. - """ - cost: CartLineCost! - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! - - """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. - """ - sellingPlanAllocation: SellingPlanAllocation -} - -""" -The cost of the merchandise line that the buyer will pay at checkout. -""" -type CartLineCost { - """ - The amount of the merchandise line. - """ - amountPerQuantity: MoneyV2! - - """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. - """ - compareAtAmountPerQuantity: MoneyV2 - - """ - The cost of the merchandise line before line-level discounts. - """ - subtotalAmount: MoneyV2! - - """ - The total cost of the merchandise line. - """ - totalAmount: MoneyV2! -} - -""" -The condition for checking the minimum quantity of products across a group of cart lines. -""" -input CartLineMinimumQuantity { - """ - Cart line IDs with a merchandise line price that's included to calculate the - minimum quantity purchased to receive the discount. - """ - ids: [ID!]! - - """ - The minimum quantity of a product. - """ - minimumQuantity: Int! -} - -""" -The condition for checking the minimum subtotal of products across a group of cart lines. -""" -input CartLineMinimumSubtotal { - """ - Cart line IDs with a merchandise line price that's included to calculate the - minimum subtotal purchased to receive the discount. - """ - ids: [ID!]! - - """ - The minimum subtotal amount of the product. - """ - minimumAmount: Decimal! -} - -""" -A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. -""" -input CartLineTarget { - """ - The ID of the targeted cart line. - """ - id: ID! - - """ - The number of line items that are being discounted. - The default value is `null`, which represents the quantity of the matching line items. - - The value is validated against: > 0. - """ - quantity: Int -} - -""" -The cart.lines.discounts.generate.fetch target result. Refer to [network access] -(https://shopify.dev/apps/build/functions/input-output/network-access/graphql) for Shopify Functions. -""" -input CartLinesDiscountsGenerateFetchResult { - """ - The http request. - """ - request: HttpRequest -} - -""" -The cart.lines.discounts.generate.run target result. -""" -input CartLinesDiscountsGenerateRunResult { - """ - The list of operations to apply discounts to the cart. - """ - operations: [CartOperation!]! -} - -""" -The operations that can be performed to apply discounts to the cart. -""" -input CartOperation @oneOf { - """ - An operation that selects which entered discount codes to accept. Use this to - validate discount codes from external systems. - """ - enteredDiscountCodesAccept: EnteredDiscountCodesAcceptOperation - - """ - An operation that applies order discounts to a cart that share a selection strategy. - """ - orderDiscountsAdd: OrderDiscountsAddOperation - - """ - An operation that applies product discounts to a cart that share a selection strategy. - """ - productDiscountsAdd: ProductDiscountsAddOperation -} - -""" -Represents whether the product is a member of the given collection. -""" -type CollectionMembership { - """ - The ID of the collection. - """ - collectionId: ID! - - """ - Whether the product is a member of the collection. - """ - isMember: Boolean! -} - -""" -Represents information about a company which is also a customer of the shop. -""" -type Company implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) at which the company was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's main point of contact. -""" -type CompanyContact { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was created in Shopify. - """ - createdAt: DateTime! - - """ - The ID of the company. - """ - id: ID! - - """ - The company contact's locale (language). - """ - locale: String - - """ - The company contact's job title. - """ - title: String - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company contact was last modified. - """ - updatedAt: DateTime! -} - -""" -A company's location. -""" -type CompanyLocation implements HasMetafields { - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was created in Shopify. - """ - createdAt: DateTime! - - """ - A unique externally-supplied ID for the company. - """ - externalId: String - - """ - The ID of the company. - """ - id: ID! - - """ - The preferred locale of the company location. - """ - locale: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the company location. - """ - name: String! - - """ - The date and time ([ISO 8601 format](http://en.wikipedia.org/wiki/ISO_8601)) - at which the company location was last modified. - """ - updatedAt: DateTime! -} - -""" -The condition to apply the discount candidate. -""" -input Condition @oneOf { - """ - The condition for checking the minimum quantity of products across a group of cart lines. - """ - cartLineMinimumQuantity: CartLineMinimumQuantity - - """ - The condition for checking the minimum subtotal of products across a group of cart lines. - """ - cartLineMinimumSubtotal: CartLineMinimumSubtotal - - """ - The condition for checking the minimum subtotal amount of the order. - """ - orderMinimumSubtotal: OrderMinimumSubtotal -} - -""" -A country. -""" -type Country { - """ - The ISO code of the country. - """ - isoCode: CountryCode! -} - -""" -The code designating a country/region, which generally follows ISO 3166-1 alpha-2 guidelines. -If a territory doesn't have a country code value in the `CountryCode` enum, then it might be considered a subdivision -of another country. For example, the territories associated with Spain are represented by the country code `ES`, -and the territories associated with the United States of America are represented by the country code `US`. -""" -enum CountryCode { - """ - Ascension Island. - """ - AC - - """ - Andorra. - """ - AD - - """ - United Arab Emirates. - """ - AE - - """ - Afghanistan. - """ - AF - - """ - Antigua & Barbuda. - """ - AG - - """ - Anguilla. - """ - AI - - """ - Albania. - """ - AL - - """ - Armenia. - """ - AM - - """ - Netherlands Antilles. - """ - AN - - """ - Angola. - """ - AO - - """ - Argentina. - """ - AR - - """ - Austria. - """ - AT - - """ - Australia. - """ - AU - - """ - Aruba. - """ - AW - - """ - Åland Islands. - """ - AX - - """ - Azerbaijan. - """ - AZ - - """ - Bosnia & Herzegovina. - """ - BA - - """ - Barbados. - """ - BB - - """ - Bangladesh. - """ - BD - - """ - Belgium. - """ - BE - - """ - Burkina Faso. - """ - BF - - """ - Bulgaria. - """ - BG - - """ - Bahrain. - """ - BH - - """ - Burundi. - """ - BI - - """ - Benin. - """ - BJ - - """ - St. Barthélemy. - """ - BL - - """ - Bermuda. - """ - BM - - """ - Brunei. - """ - BN - - """ - Bolivia. - """ - BO - - """ - Caribbean Netherlands. - """ - BQ - - """ - Brazil. - """ - BR - - """ - Bahamas. - """ - BS - - """ - Bhutan. - """ - BT - - """ - Bouvet Island. - """ - BV - - """ - Botswana. - """ - BW - - """ - Belarus. - """ - BY - - """ - Belize. - """ - BZ - - """ - Canada. - """ - CA - - """ - Cocos (Keeling) Islands. - """ - CC - - """ - Congo - Kinshasa. - """ - CD - - """ - Central African Republic. - """ - CF - - """ - Congo - Brazzaville. - """ - CG - - """ - Switzerland. - """ - CH - - """ - Côte d’Ivoire. - """ - CI - - """ - Cook Islands. - """ - CK - - """ - Chile. - """ - CL - - """ - Cameroon. - """ - CM - - """ - China. - """ - CN - - """ - Colombia. - """ - CO - - """ - Costa Rica. - """ - CR - - """ - Cuba. - """ - CU - - """ - Cape Verde. - """ - CV - - """ - Curaçao. - """ - CW - - """ - Christmas Island. - """ - CX - - """ - Cyprus. - """ - CY - - """ - Czechia. - """ - CZ - - """ - Germany. - """ - DE - - """ - Djibouti. - """ - DJ - - """ - Denmark. - """ - DK - - """ - Dominica. - """ - DM - - """ - Dominican Republic. - """ - DO - - """ - Algeria. - """ - DZ - - """ - Ecuador. - """ - EC - - """ - Estonia. - """ - EE - - """ - Egypt. - """ - EG - - """ - Western Sahara. - """ - EH - - """ - Eritrea. - """ - ER - - """ - Spain. - """ - ES - - """ - Ethiopia. - """ - ET - - """ - Finland. - """ - FI - - """ - Fiji. - """ - FJ - - """ - Falkland Islands. - """ - FK - - """ - Faroe Islands. - """ - FO - - """ - France. - """ - FR - - """ - Gabon. - """ - GA - - """ - United Kingdom. - """ - GB - - """ - Grenada. - """ - GD - - """ - Georgia. - """ - GE - - """ - French Guiana. - """ - GF - - """ - Guernsey. - """ - GG - - """ - Ghana. - """ - GH - - """ - Gibraltar. - """ - GI - - """ - Greenland. - """ - GL - - """ - Gambia. - """ - GM - - """ - Guinea. - """ - GN - - """ - Guadeloupe. - """ - GP - - """ - Equatorial Guinea. - """ - GQ - - """ - Greece. - """ - GR - - """ - South Georgia & South Sandwich Islands. - """ - GS - - """ - Guatemala. - """ - GT - - """ - Guinea-Bissau. - """ - GW - - """ - Guyana. - """ - GY - - """ - Hong Kong SAR. - """ - HK - - """ - Heard & McDonald Islands. - """ - HM - - """ - Honduras. - """ - HN - - """ - Croatia. - """ - HR - - """ - Haiti. - """ - HT - - """ - Hungary. - """ - HU - - """ - Indonesia. - """ - ID - - """ - Ireland. - """ - IE - - """ - Israel. - """ - IL - - """ - Isle of Man. - """ - IM - - """ - India. - """ - IN - - """ - British Indian Ocean Territory. - """ - IO - - """ - Iraq. - """ - IQ - - """ - Iran. - """ - IR - - """ - Iceland. - """ - IS - - """ - Italy. - """ - IT - - """ - Jersey. - """ - JE - - """ - Jamaica. - """ - JM - - """ - Jordan. - """ - JO - - """ - Japan. - """ - JP - - """ - Kenya. - """ - KE - - """ - Kyrgyzstan. - """ - KG - - """ - Cambodia. - """ - KH - - """ - Kiribati. - """ - KI - - """ - Comoros. - """ - KM - - """ - St. Kitts & Nevis. - """ - KN - - """ - North Korea. - """ - KP - - """ - South Korea. - """ - KR - - """ - Kuwait. - """ - KW - - """ - Cayman Islands. - """ - KY - - """ - Kazakhstan. - """ - KZ - - """ - Laos. - """ - LA - - """ - Lebanon. - """ - LB - - """ - St. Lucia. - """ - LC - - """ - Liechtenstein. - """ - LI - - """ - Sri Lanka. - """ - LK - - """ - Liberia. - """ - LR - - """ - Lesotho. - """ - LS - - """ - Lithuania. - """ - LT - - """ - Luxembourg. - """ - LU - - """ - Latvia. - """ - LV - - """ - Libya. - """ - LY - - """ - Morocco. - """ - MA - - """ - Monaco. - """ - MC - - """ - Moldova. - """ - MD - - """ - Montenegro. - """ - ME - - """ - St. Martin. - """ - MF - - """ - Madagascar. - """ - MG - - """ - North Macedonia. - """ - MK - - """ - Mali. - """ - ML - - """ - Myanmar (Burma). - """ - MM - - """ - Mongolia. - """ - MN - - """ - Macao SAR. - """ - MO - - """ - Martinique. - """ - MQ - - """ - Mauritania. - """ - MR - - """ - Montserrat. - """ - MS - - """ - Malta. - """ - MT - - """ - Mauritius. - """ - MU - - """ - Maldives. - """ - MV - - """ - Malawi. - """ - MW - - """ - Mexico. - """ - MX - - """ - Malaysia. - """ - MY - - """ - Mozambique. - """ - MZ - - """ - Namibia. - """ - NA - - """ - New Caledonia. - """ - NC - - """ - Niger. - """ - NE - - """ - Norfolk Island. - """ - NF - - """ - Nigeria. - """ - NG - - """ - Nicaragua. - """ - NI - - """ - Netherlands. - """ - NL - - """ - Norway. - """ - NO - - """ - Nepal. - """ - NP - - """ - Nauru. - """ - NR - - """ - Niue. - """ - NU - - """ - New Zealand. - """ - NZ - - """ - Oman. - """ - OM - - """ - Panama. - """ - PA - - """ - Peru. - """ - PE - - """ - French Polynesia. - """ - PF - - """ - Papua New Guinea. - """ - PG - - """ - Philippines. - """ - PH - - """ - Pakistan. - """ - PK - - """ - Poland. - """ - PL - - """ - St. Pierre & Miquelon. - """ - PM - - """ - Pitcairn Islands. - """ - PN - - """ - Palestinian Territories. - """ - PS - - """ - Portugal. - """ - PT - - """ - Paraguay. - """ - PY - - """ - Qatar. - """ - QA - - """ - Réunion. - """ - RE - - """ - Romania. - """ - RO - - """ - Serbia. - """ - RS - - """ - Russia. - """ - RU - - """ - Rwanda. - """ - RW - - """ - Saudi Arabia. - """ - SA - - """ - Solomon Islands. - """ - SB - - """ - Seychelles. - """ - SC - - """ - Sudan. - """ - SD - - """ - Sweden. - """ - SE - - """ - Singapore. - """ - SG - - """ - St. Helena. - """ - SH - - """ - Slovenia. - """ - SI - - """ - Svalbard & Jan Mayen. - """ - SJ - - """ - Slovakia. - """ - SK - - """ - Sierra Leone. - """ - SL - - """ - San Marino. - """ - SM - - """ - Senegal. - """ - SN - - """ - Somalia. - """ - SO - - """ - Suriname. - """ - SR - - """ - South Sudan. - """ - SS - - """ - São Tomé & Príncipe. - """ - ST - - """ - El Salvador. - """ - SV - - """ - Sint Maarten. - """ - SX - - """ - Syria. - """ - SY - - """ - Eswatini. - """ - SZ - - """ - Tristan da Cunha. - """ - TA - - """ - Turks & Caicos Islands. - """ - TC - - """ - Chad. - """ - TD - - """ - French Southern Territories. - """ - TF - - """ - Togo. - """ - TG - - """ - Thailand. - """ - TH - - """ - Tajikistan. - """ - TJ - - """ - Tokelau. - """ - TK - - """ - Timor-Leste. - """ - TL - - """ - Turkmenistan. - """ - TM - - """ - Tunisia. - """ - TN - - """ - Tonga. - """ - TO - - """ - Türkiye. - """ - TR - - """ - Trinidad & Tobago. - """ - TT - - """ - Tuvalu. - """ - TV - - """ - Taiwan. - """ - TW - - """ - Tanzania. - """ - TZ - - """ - Ukraine. - """ - UA - - """ - Uganda. - """ - UG - - """ - U.S. Outlying Islands. - """ - UM - - """ - United States. - """ - US - - """ - Uruguay. - """ - UY - - """ - Uzbekistan. - """ - UZ - - """ - Vatican City. - """ - VA - - """ - St. Vincent & Grenadines. - """ - VC - - """ - Venezuela. - """ - VE - - """ - British Virgin Islands. - """ - VG - - """ - Vietnam. - """ - VN - - """ - Vanuatu. - """ - VU - - """ - Wallis & Futuna. - """ - WF - - """ - Samoa. - """ - WS - - """ - Kosovo. - """ - XK - - """ - Yemen. - """ - YE - - """ - Mayotte. - """ - YT - - """ - South Africa. - """ - ZA - - """ - Zambia. - """ - ZM - - """ - Zimbabwe. - """ - ZW - - """ - Unknown Region. - """ - ZZ -} - -""" -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. -""" -enum CurrencyCode { - """ - United Arab Emirates Dirham (AED). - """ - AED - - """ - Afghan Afghani (AFN). - """ - AFN - - """ - Albanian Lek (ALL). - """ - ALL - - """ - Armenian Dram (AMD). - """ - AMD - - """ - Netherlands Antillean Guilder. - """ - ANG - - """ - Angolan Kwanza (AOA). - """ - AOA - - """ - Argentine Pesos (ARS). - """ - ARS - - """ - Australian Dollars (AUD). - """ - AUD - - """ - Aruban Florin (AWG). - """ - AWG - - """ - Azerbaijani Manat (AZN). - """ - AZN - - """ - Bosnia and Herzegovina Convertible Mark (BAM). - """ - BAM - - """ - Barbadian Dollar (BBD). - """ - BBD - - """ - Bangladesh Taka (BDT). - """ - BDT - - """ - Bulgarian Lev (BGN). - """ - BGN - - """ - Bahraini Dinar (BHD). - """ - BHD - - """ - Burundian Franc (BIF). - """ - BIF - - """ - Bermudian Dollar (BMD). - """ - BMD - - """ - Brunei Dollar (BND). - """ - BND - - """ - Bolivian Boliviano (BOB). - """ - BOB - - """ - Brazilian Real (BRL). - """ - BRL - - """ - Bahamian Dollar (BSD). - """ - BSD - - """ - Bhutanese Ngultrum (BTN). - """ - BTN - - """ - Botswana Pula (BWP). - """ - BWP - - """ - Belarusian Ruble (BYN). - """ - BYN - - """ - Belarusian Ruble (BYR). - """ - BYR @deprecated(reason: "`BYR` is deprecated. Use `BYN` available from version `2021-01` onwards instead.") - - """ - Belize Dollar (BZD). - """ - BZD - - """ - Canadian Dollars (CAD). - """ - CAD - - """ - Congolese franc (CDF). - """ - CDF - - """ - Swiss Francs (CHF). - """ - CHF - - """ - Chilean Peso (CLP). - """ - CLP - - """ - Chinese Yuan Renminbi (CNY). - """ - CNY - - """ - Colombian Peso (COP). - """ - COP - - """ - Costa Rican Colones (CRC). - """ - CRC - - """ - Cape Verdean escudo (CVE). - """ - CVE - - """ - Czech Koruny (CZK). - """ - CZK - - """ - Djiboutian Franc (DJF). - """ - DJF - - """ - Danish Kroner (DKK). - """ - DKK - - """ - Dominican Peso (DOP). - """ - DOP - - """ - Algerian Dinar (DZD). - """ - DZD - - """ - Egyptian Pound (EGP). - """ - EGP - - """ - Eritrean Nakfa (ERN). - """ - ERN - - """ - Ethiopian Birr (ETB). - """ - ETB - - """ - Euro (EUR). - """ - EUR - - """ - Fijian Dollars (FJD). - """ - FJD - - """ - Falkland Islands Pounds (FKP). - """ - FKP - - """ - United Kingdom Pounds (GBP). - """ - GBP - - """ - Georgian Lari (GEL). - """ - GEL - - """ - Ghanaian Cedi (GHS). - """ - GHS - - """ - Gibraltar Pounds (GIP). - """ - GIP - - """ - Gambian Dalasi (GMD). - """ - GMD - - """ - Guinean Franc (GNF). - """ - GNF - - """ - Guatemalan Quetzal (GTQ). - """ - GTQ - - """ - Guyanese Dollar (GYD). - """ - GYD - - """ - Hong Kong Dollars (HKD). - """ - HKD - - """ - Honduran Lempira (HNL). - """ - HNL - - """ - Croatian Kuna (HRK). - """ - HRK - - """ - Haitian Gourde (HTG). - """ - HTG - - """ - Hungarian Forint (HUF). - """ - HUF - - """ - Indonesian Rupiah (IDR). - """ - IDR - - """ - Israeli New Shekel (NIS). - """ - ILS - - """ - Indian Rupees (INR). - """ - INR - - """ - Iraqi Dinar (IQD). - """ - IQD - - """ - Iranian Rial (IRR). - """ - IRR - - """ - Icelandic Kronur (ISK). - """ - ISK - - """ - Jersey Pound. - """ - JEP - - """ - Jamaican Dollars (JMD). - """ - JMD - - """ - Jordanian Dinar (JOD). - """ - JOD - - """ - Japanese Yen (JPY). - """ - JPY - - """ - Kenyan Shilling (KES). - """ - KES - - """ - Kyrgyzstani Som (KGS). - """ - KGS - - """ - Cambodian Riel. - """ - KHR - - """ - Kiribati Dollar (KID). - """ - KID - - """ - Comorian Franc (KMF). - """ - KMF - - """ - South Korean Won (KRW). - """ - KRW - - """ - Kuwaiti Dinar (KWD). - """ - KWD - - """ - Cayman Dollars (KYD). - """ - KYD - - """ - Kazakhstani Tenge (KZT). - """ - KZT - - """ - Laotian Kip (LAK). - """ - LAK - - """ - Lebanese Pounds (LBP). - """ - LBP - - """ - Sri Lankan Rupees (LKR). - """ - LKR - - """ - Liberian Dollar (LRD). - """ - LRD - - """ - Lesotho Loti (LSL). - """ - LSL - - """ - Lithuanian Litai (LTL). - """ - LTL - - """ - Latvian Lati (LVL). - """ - LVL - - """ - Libyan Dinar (LYD). - """ - LYD - - """ - Moroccan Dirham. - """ - MAD - - """ - Moldovan Leu (MDL). - """ - MDL - - """ - Malagasy Ariary (MGA). - """ - MGA - - """ - Macedonia Denar (MKD). - """ - MKD - - """ - Burmese Kyat (MMK). - """ - MMK - - """ - Mongolian Tugrik. - """ - MNT - - """ - Macanese Pataca (MOP). - """ - MOP - - """ - Mauritanian Ouguiya (MRU). - """ - MRU - - """ - Mauritian Rupee (MUR). - """ - MUR - - """ - Maldivian Rufiyaa (MVR). - """ - MVR - - """ - Malawian Kwacha (MWK). - """ - MWK - - """ - Mexican Pesos (MXN). - """ - MXN - - """ - Malaysian Ringgits (MYR). - """ - MYR - - """ - Mozambican Metical. - """ - MZN - - """ - Namibian Dollar. - """ - NAD - - """ - Nigerian Naira (NGN). - """ - NGN - - """ - Nicaraguan Córdoba (NIO). - """ - NIO - - """ - Norwegian Kroner (NOK). - """ - NOK - - """ - Nepalese Rupee (NPR). - """ - NPR - - """ - New Zealand Dollars (NZD). - """ - NZD - - """ - Omani Rial (OMR). - """ - OMR - - """ - Panamian Balboa (PAB). - """ - PAB - - """ - Peruvian Nuevo Sol (PEN). - """ - PEN - - """ - Papua New Guinean Kina (PGK). - """ - PGK - - """ - Philippine Peso (PHP). - """ - PHP - - """ - Pakistani Rupee (PKR). - """ - PKR - - """ - Polish Zlotych (PLN). - """ - PLN - - """ - Paraguayan Guarani (PYG). - """ - PYG - - """ - Qatari Rial (QAR). - """ - QAR - - """ - Romanian Lei (RON). - """ - RON - - """ - Serbian dinar (RSD). - """ - RSD - - """ - Russian Rubles (RUB). - """ - RUB - - """ - Rwandan Franc (RWF). - """ - RWF - - """ - Saudi Riyal (SAR). - """ - SAR - - """ - Solomon Islands Dollar (SBD). - """ - SBD - - """ - Seychellois Rupee (SCR). - """ - SCR - - """ - Sudanese Pound (SDG). - """ - SDG - - """ - Swedish Kronor (SEK). - """ - SEK - - """ - Singapore Dollars (SGD). - """ - SGD - - """ - Saint Helena Pounds (SHP). - """ - SHP - - """ - Sierra Leonean Leone (SLL). - """ - SLL - - """ - Somali Shilling (SOS). - """ - SOS - - """ - Surinamese Dollar (SRD). - """ - SRD - - """ - South Sudanese Pound (SSP). - """ - SSP - - """ - Sao Tome And Principe Dobra (STD). - """ - STD @deprecated(reason: "`STD` is deprecated. Use `STN` available from version `2022-07` onwards instead.") - - """ - Sao Tome And Principe Dobra (STN). - """ - STN - - """ - Syrian Pound (SYP). - """ - SYP - - """ - Swazi Lilangeni (SZL). - """ - SZL - - """ - Thai baht (THB). - """ - THB - - """ - Tajikistani Somoni (TJS). - """ - TJS - - """ - Turkmenistani Manat (TMT). - """ - TMT - - """ - Tunisian Dinar (TND). - """ - TND - - """ - Tongan Pa'anga (TOP). - """ - TOP - - """ - Turkish Lira (TRY). - """ - TRY - - """ - Trinidad and Tobago Dollars (TTD). - """ - TTD - - """ - Taiwan Dollars (TWD). - """ - TWD - - """ - Tanzanian Shilling (TZS). - """ - TZS - - """ - Ukrainian Hryvnia (UAH). - """ - UAH - - """ - Ugandan Shilling (UGX). - """ - UGX - - """ - United States Dollars (USD). - """ - USD - - """ - Uruguayan Pesos (UYU). - """ - UYU - - """ - Uzbekistan som (UZS). - """ - UZS - - """ - Venezuelan Bolivares (VED). - """ - VED - - """ - Venezuelan Bolivares (VEF). - """ - VEF @deprecated(reason: "`VEF` is deprecated. Use `VES` available from version `2020-10` onwards instead.") - - """ - Venezuelan Bolivares Soberanos (VES). - """ - VES - - """ - Vietnamese đồng (VND). - """ - VND - - """ - Vanuatu Vatu (VUV). - """ - VUV - - """ - Samoan Tala (WST). - """ - WST - - """ - Central African CFA Franc (XAF). - """ - XAF - - """ - East Caribbean Dollar (XCD). - """ - XCD - - """ - West African CFA franc (XOF). - """ - XOF - - """ - CFP Franc (XPF). - """ - XPF - - """ - Unrecognized currency. - """ - XXX - - """ - Yemeni Rial (YER). - """ - YER - - """ - South African Rand (ZAR). - """ - ZAR - - """ - Zambian Kwacha (ZMW). - """ - ZMW -} - -""" -A custom product. -""" -type CustomProduct { - """ - Whether the merchandise is a gift card. - """ - isGiftCard: Boolean! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents a customer with the shop. -""" -type Customer implements HasMetafields { - """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. - """ - amountSpent: MoneyV2! - - """ - The customer’s name, email or phone number. - """ - displayName: String! - - """ - The customer’s email address. - """ - email: String - - """ - The customer's first name. - """ - firstName: String - - """ - Whether the customer has any of the given tags. - """ - hasAnyTag( - """ - The tags to search for. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the customer has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A unique identifier for the customer. - """ - id: ID! - - """ - The customer's last name. - """ - lastName: String - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The number of orders made by the customer. - """ - numberOfOrders: Int! -} - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date string. -For example, September 7, 2019 is represented as `"2019-07-16"`. -""" -scalar Date - -""" -Represents an [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601)-encoded date and time string. -For example, 3:50 pm on September 7, 2019 in the time zone of UTC (Coordinated Universal Time) is -represented as `"2019-09-07T15:50:00Z`". -""" -scalar DateTime - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the date and time but not the timezone which is determined from context. - -For example, "2018-01-01T00:00:00". -""" -scalar DateTimeWithoutTimezone - -""" -A signed decimal number, which supports arbitrary precision and is serialized as a string. - -Example values: `"29.99"`, `"29.999"`. -""" -scalar Decimal - -""" -Represents information about the merchandise in the cart. -""" -type DeliverableCartLine { - """ - Retrieve a cart line attribute by key. - - Cart line attributes are also known as line item properties in Liquid. - """ - attribute( - """ - The key of the attribute to retrieve. - """ - key: String - ): Attribute - - """ - The ID of the cart line. - """ - id: ID! - - """ - The merchandise that the buyer intends to purchase. - """ - merchandise: Merchandise! - - """ - The quantity of the merchandise that the customer intends to purchase. - """ - quantity: Int! -} - -""" -The delivery discount candidate to be applied. -""" -input DeliveryDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The discount message. - """ - message: String - - """ - The targets of the delivery discount candidate. - """ - targets: [DeliveryDiscountCandidateTarget!]! - - """ - The value of the delivery discount candidate. - """ - value: DeliveryDiscountCandidateValue! -} - -""" -The target of the delivery discount candidate. -""" -input DeliveryDiscountCandidateTarget @oneOf { - """ - The target delivery group. - """ - deliveryGroup: DeliveryGroupTarget - - """ - The target delivery option. - """ - deliveryOption: DeliveryOptionTarget -} - -""" -The delivery discount candidate value. -""" -input DeliveryDiscountCandidateValue @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of delivery discount candidates. -""" -enum DeliveryDiscountSelectionStrategy { - """ - Apply all delivery discount candidates with conditions that are satisfied. This does not override - discount combination or stacking rules. - """ - ALL -} - -""" -An operation that applies delivery discounts to a cart that share a selection strategy. -""" -input DeliveryDiscountsAddOperation { - """ - The list of delivery discount candidates to be applied. - """ - candidates: [DeliveryDiscountCandidate!]! - - """ - The strategy that's applied to the list of discounts. - """ - selectionStrategy: DeliveryDiscountSelectionStrategy! -} - -""" -The target delivery group. -""" -input DeliveryGroupTarget { - """ - The ID of the target delivery group. - """ - id: ID! -} - -""" -List of different delivery method types. -""" -enum DeliveryMethod { - """ - Local Delivery. - """ - LOCAL - - """ - None. - """ - NONE - - """ - Shipping to a Pickup Point. - """ - PICKUP_POINT - - """ - Local Pickup. - """ - PICK_UP - - """ - Retail. - """ - RETAIL - - """ - Shipping. - """ - SHIPPING -} - -""" -The operations that can be performed to apply discounts to the delivery lines. -""" -input DeliveryOperation @oneOf { - """ - An operation that applies delivery discounts to a cart that share a selection strategy. - """ - deliveryDiscountsAdd: DeliveryDiscountsAddOperation - - """ - An operation that selects which entered discount codes to accept. Use this to - validate discount codes from external systems. - """ - enteredDiscountCodesAccept: EnteredDiscountCodesAcceptOperation -} - -""" -The target delivery option. -""" -input DeliveryOptionTarget { - """ - The handle of the target delivery option. - """ - handle: Handle! -} - -""" -The discount that invoked the Function. -""" -type Discount implements HasMetafields { - """ - The discount classes supported by the discount node. - """ - discountClasses: [DiscountClass!]! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -The [discount class](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) -that's used to control how discounts can be combined. -""" -enum DiscountClass { - """ - The discount is combined with an - [order discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - ORDER - - """ - The discount is combined with a - [product discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - PRODUCT - - """ - The discount is combined with a - [shipping discount](https://help.shopify.com/manual/discounts/combining-discounts/discount-combinations) - class. - """ - SHIPPING -} - -""" -A discount code used by the buyer to add a discount to the cart. -""" -input DiscountCode { - """ - The discount code. - """ - code: String! -} - -""" -An operation that selects which entered discount codes to accept. Use this to validate discount codes from external systems. -""" -input EnteredDiscountCodesAcceptOperation { - """ - The list of discount codes to accept. - """ - codes: [DiscountCode!]! -} - -""" -A fixed amount value. -""" -input FixedAmount { - """ - The fixed amount value of the discount, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! -} - -""" -Represents a gate configuration. -""" -type GateConfiguration implements HasMetafields { - """ - An optional string identifier. - """ - appId: String - - """ - A non-unique string used to group gate configurations. - """ - handle: Handle - - """ - The ID of the gate configuration. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents a connection from a subject to a gate configuration. -""" -type GateSubject { - """ - The bound gate configuration. - """ - configuration( - """ - The appId of the gate configurations to search for. - """ - appId: String @deprecated(reason: "Use GateSubject.handle to filter gates instead.") - ): GateConfiguration! - - """ - The ID of the gate subject. - """ - id: ID! -} - -""" -A function-scoped handle to a refer a resource. -The Handle type appears in a JSON response as a String, but it is not intended to be human-readable. -Example value: `"10079785100"` -""" -scalar Handle - -""" -Gate subjects associated to the specified resource. -""" -interface HasGates { - """ - Returns active gate subjects bound to the resource. - """ - gates( - """ - The handle of the gate configurations to search for. - """ - handle: Handle - ): [GateSubject!]! @deprecated(reason: "Gates API is being sunset and will be removed in a future version. Use `metafields` instead for gate configuration.") -} - -""" -Represents information about the metafields associated to the specified resource. -""" -interface HasMetafields { - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -Represents whether the current object has the given tag. -""" -type HasTagResponse { - """ - Whether the current object has the tag. - """ - hasTag: Boolean! - - """ - The tag. - """ - tag: String! -} - -""" -The attributes associated with an HTTP request. -""" -input HttpRequest { - """ - The HTTP request body as a plain string. - Use this field when the body isn't in JSON format. - """ - body: String - - """ - The HTTP headers. - """ - headers: [HttpRequestHeader!]! - - """ - The HTTP request body as a JSON object. - Use this field when the body's in JSON format, to reduce function instruction consumption - and to ensure the body's formatted in logs. - Don't use this field together with the `body` field. If both are provided, then the `body` field - will take precedence. - If this field is specified and no `Content-Type` header is included, then the header will - automatically be set to `application/json`. - """ - jsonBody: JSON - - """ - The HTTP method. - """ - method: HttpRequestMethod! - - """ - Policy attached to the HTTP request. - """ - policy: HttpRequestPolicy! - - """ - The HTTP url (eg.: https://example.com). The scheme needs to be HTTPS. - """ - url: URL! -} - -""" -The attributes associated with an HTTP request header. -""" -input HttpRequestHeader { - """ - Header name. - """ - name: String! - - """ - Header value. - """ - value: String! -} - -""" -The HTTP request available methods. -""" -enum HttpRequestMethod { - """ - Http GET. - """ - GET - - """ - Http POST. - """ - POST -} - -""" -The attributes associated with an HTTP request policy. -""" -input HttpRequestPolicy { - """ - Read timeout in milliseconds. - """ - readTimeoutMs: Int! -} - -""" -The attributes associated with an HTTP response. -""" -type HttpResponse { - """ - The HTTP response body as a plain string. - Use this field when the body is not in JSON format. - """ - body: String - - """ - An HTTP header. - """ - header( - """ - A case-insensitive header name. - """ - name: String! - ): HttpResponseHeader - - """ - The HTTP headers. - """ - headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") - - """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. - Use this field when you expect the response to be JSON, or when you're dealing - with mixed response types, meaning both JSON and non-JSON. - Using this field reduces function instruction consumption and ensures that the data is formatted in logs. - To prevent increasing the function target input size unnecessarily, avoid querying - both `body` and `jsonBody` simultaneously. - """ - jsonBody: JSON - - """ - The HTTP status code. - """ - status: Int! -} - -""" -The attributes associated with an HTTP response header. -""" -type HttpResponseHeader { - """ - Header name. - """ - name: String! - - """ - Header value. - """ - value: String! -} - -""" -Represents a unique identifier, often used to refetch an object. -The ID type appears in a JSON response as a String, but it is not intended to be human-readable. - -Example value: `"gid://shopify/Product/10079785100"` -""" -scalar ID - -""" -The input object for the Function. -""" -type Input { - """ - The cart. - """ - cart: Cart! - - """ - The discount node executing the Function. - """ - discount: Discount! - - """ - Discount codes entered by the buyer as an array of strings, excluding gift cards. - Codes are not validated in any way other than gift card filtering. - """ - enteredDiscountCodes: [String!]! @restrictTarget(only: ["cart.lines.discounts.generate.fetch", "cart.delivery-options.discounts.generate.fetch"]) - - """ - The result of the fetch target. Refer to [network access](https://shopify.dev/apps/build/functions/input-output/network-access/graphql) - for Shopify Functions. - """ - fetchResult: HttpResponse @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) - - """ - The localization of the Function execution context. - """ - localization: Localization! - - """ - The conversion rate between the shop's currency and the currency of the cart. - """ - presentmentCurrencyRate: Decimal! - - """ - Information about the shop. - """ - shop: Shop! - - """ - The discount code entered by the buyer that caused the Function to run. - This input is only available in the cart.lines.discounts.generate.run - and cart.delivery-options.discounts.generate.run extension targets. - """ - triggeringDiscountCode: String @restrictTarget(only: ["cart.lines.discounts.generate.run", "cart.delivery-options.discounts.generate.run"]) -} - -""" -A [JSON](https://www.json.org/json-en.html) object. - -Example value: -`{ - "product": { - "id": "gid://shopify/Product/1346443542550", - "title": "White T-shirt", - "options": [{ - "name": "Size", - "values": ["M", "L"] - }] - } -}` -""" -scalar JSON - -""" -A language. -""" -type Language { - """ - The ISO code. - """ - isoCode: LanguageCode! -} - -""" -Language codes supported by Shopify. -""" -enum LanguageCode { - """ - Afrikaans. - """ - AF - - """ - Akan. - """ - AK - - """ - Amharic. - """ - AM - - """ - Arabic. - """ - AR - - """ - Assamese. - """ - AS - - """ - Azerbaijani. - """ - AZ - - """ - Belarusian. - """ - BE - - """ - Bulgarian. - """ - BG - - """ - Bambara. - """ - BM - - """ - Bangla. - """ - BN - - """ - Tibetan. - """ - BO - - """ - Breton. - """ - BR - - """ - Bosnian. - """ - BS - - """ - Catalan. - """ - CA - - """ - Chechen. - """ - CE - - """ - Central Kurdish. - """ - CKB - - """ - Czech. - """ - CS - - """ - Church Slavic. - """ - CU - - """ - Welsh. - """ - CY - - """ - Danish. - """ - DA - - """ - German. - """ - DE - - """ - Dzongkha. - """ - DZ - - """ - Ewe. - """ - EE - - """ - Greek. - """ - EL - - """ - English. - """ - EN - - """ - Esperanto. - """ - EO - - """ - Spanish. - """ - ES - - """ - Estonian. - """ - ET - - """ - Basque. - """ - EU - - """ - Persian. - """ - FA - - """ - Fulah. - """ - FF - - """ - Finnish. - """ - FI - - """ - Filipino. - """ - FIL - - """ - Faroese. - """ - FO - - """ - French. - """ - FR - - """ - Western Frisian. - """ - FY - - """ - Irish. - """ - GA - - """ - Scottish Gaelic. - """ - GD - - """ - Galician. - """ - GL - - """ - Gujarati. - """ - GU - - """ - Manx. - """ - GV - - """ - Hausa. - """ - HA - - """ - Hebrew. - """ - HE - - """ - Hindi. - """ - HI - - """ - Croatian. - """ - HR - - """ - Hungarian. - """ - HU - - """ - Armenian. - """ - HY - - """ - Interlingua. - """ - IA - - """ - Indonesian. - """ - ID - - """ - Igbo. - """ - IG - - """ - Sichuan Yi. - """ - II - - """ - Icelandic. - """ - IS - - """ - Italian. - """ - IT - - """ - Japanese. - """ - JA - - """ - Javanese. - """ - JV - - """ - Georgian. - """ - KA - - """ - Kikuyu. - """ - KI - - """ - Kazakh. - """ - KK - - """ - Kalaallisut. - """ - KL - - """ - Khmer. - """ - KM - - """ - Kannada. - """ - KN - - """ - Korean. - """ - KO - - """ - Kashmiri. - """ - KS - - """ - Kurdish. - """ - KU - - """ - Cornish. - """ - KW - - """ - Kyrgyz. - """ - KY - - """ - Luxembourgish. - """ - LB - - """ - Ganda. - """ - LG - - """ - Lingala. - """ - LN - - """ - Lao. - """ - LO - - """ - Lithuanian. - """ - LT - - """ - Luba-Katanga. - """ - LU - - """ - Latvian. - """ - LV - - """ - Malagasy. - """ - MG - - """ - Māori. - """ - MI - - """ - Macedonian. - """ - MK - - """ - Malayalam. - """ - ML - - """ - Mongolian. - """ - MN - - """ - Marathi. - """ - MR - - """ - Malay. - """ - MS - - """ - Maltese. - """ - MT - - """ - Burmese. - """ - MY - - """ - Norwegian (Bokmål). - """ - NB - - """ - North Ndebele. - """ - ND - - """ - Nepali. - """ - NE - - """ - Dutch. - """ - NL - - """ - Norwegian Nynorsk. - """ - NN - - """ - Norwegian. - """ - NO - - """ - Oromo. - """ - OM - - """ - Odia. - """ - OR - - """ - Ossetic. - """ - OS - - """ - Punjabi. - """ - PA - - """ - Polish. - """ - PL - - """ - Pashto. - """ - PS - - """ - Portuguese. - """ - PT - - """ - Portuguese (Brazil). - """ - PT_BR - - """ - Portuguese (Portugal). - """ - PT_PT - - """ - Quechua. - """ - QU - - """ - Romansh. - """ - RM - - """ - Rundi. - """ - RN - - """ - Romanian. - """ - RO - - """ - Russian. - """ - RU - - """ - Kinyarwanda. - """ - RW - - """ - Sanskrit. - """ - SA - - """ - Sardinian. - """ - SC - - """ - Sindhi. - """ - SD - - """ - Northern Sami. - """ - SE - - """ - Sango. - """ - SG - - """ - Sinhala. - """ - SI - - """ - Slovak. - """ - SK - - """ - Slovenian. - """ - SL - - """ - Shona. - """ - SN - - """ - Somali. - """ - SO - - """ - Albanian. - """ - SQ - - """ - Serbian. - """ - SR - - """ - Sundanese. - """ - SU - - """ - Swedish. - """ - SV - - """ - Swahili. - """ - SW - - """ - Tamil. - """ - TA - - """ - Telugu. - """ - TE - - """ - Tajik. - """ - TG - - """ - Thai. - """ - TH - - """ - Tigrinya. - """ - TI - - """ - Turkmen. - """ - TK - - """ - Tongan. - """ - TO - - """ - Turkish. - """ - TR - - """ - Tatar. - """ - TT - - """ - Uyghur. - """ - UG - - """ - Ukrainian. - """ - UK - - """ - Urdu. - """ - UR - - """ - Uzbek. - """ - UZ - - """ - Vietnamese. - """ - VI - - """ - Volapük. - """ - VO - - """ - Wolof. - """ - WO - - """ - Xhosa. - """ - XH - - """ - Yiddish. - """ - YI - - """ - Yoruba. - """ - YO - - """ - Chinese. - """ - ZH - - """ - Chinese (Simplified). - """ - ZH_CN - - """ - Chinese (Traditional). - """ - ZH_TW - - """ - Zulu. - """ - ZU -} - -""" -Represents limited information about the current time relative to the parent object. -""" -type LocalTime { - """ - The current date relative to the parent object. - """ - date: Date! - - """ - Returns true if the current date and time is at or past the given date and time, and false otherwise. - """ - dateTimeAfter( - """ - The date and time to compare against, assumed to be in the timezone of the parent object. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is before the given date and time, and false otherwise. - """ - dateTimeBefore( - """ - The date and time to compare against, assumed to be in the timezone of the parent timezone. - """ - dateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current date and time is between the two given date and times, and false otherwise. - """ - dateTimeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endDateTime: DateTimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startDateTime: DateTimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeAfter( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is at or past the given time, and false otherwise. - """ - timeBefore( - """ - The time to compare against, assumed to be in the timezone of the parent timezone. - """ - time: TimeWithoutTimezone! - ): Boolean! - - """ - Returns true if the current time is between the two given times, and false otherwise. - """ - timeBetween( - """ - The upper bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - endTime: TimeWithoutTimezone! - - """ - The lower bound time to compare against, assumed to be in the timezone of the parent timezone. - """ - startTime: TimeWithoutTimezone! - ): Boolean! -} - -""" -Information about the localized experiences configured for the shop. -""" -type Localization { - """ - The country of the active localized experience. - """ - country: Country! - - """ - The language of the active localized experience. - """ - language: Language! - - """ - The market of the active localized experience. - """ - market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") -} - -""" -Represents the value captured by a localized field. Localized fields are -additional fields required by certain countries on international orders. For -example, some countries require additional fields for customs information or tax -identification numbers. -""" -type LocalizedField { - """ - The key of the localized field. - """ - key: LocalizedFieldKey! - - """ - The title of the localized field. - """ - title: String! - - """ - The value of the localized field. - """ - value: String -} - -""" -Unique key identifying localized fields. -""" -enum LocalizedFieldKey { - """ - Localized field key 'shipping_credential_br' for country Brazil. - """ - SHIPPING_CREDENTIAL_BR - - """ - Localized field key 'shipping_credential_cl' for country Chile. - """ - SHIPPING_CREDENTIAL_CL - - """ - Localized field key 'shipping_credential_cn' for country China. - """ - SHIPPING_CREDENTIAL_CN - - """ - Localized field key 'shipping_credential_co' for country Colombia. - """ - SHIPPING_CREDENTIAL_CO - - """ - Localized field key 'shipping_credential_cr' for country Costa Rica. - """ - SHIPPING_CREDENTIAL_CR - - """ - Localized field key 'shipping_credential_ec' for country Ecuador. - """ - SHIPPING_CREDENTIAL_EC - - """ - Localized field key 'shipping_credential_es' for country Spain. - """ - SHIPPING_CREDENTIAL_ES - - """ - Localized field key 'shipping_credential_gt' for country Guatemala. - """ - SHIPPING_CREDENTIAL_GT - - """ - Localized field key 'shipping_credential_id' for country Indonesia. - """ - SHIPPING_CREDENTIAL_ID - - """ - Localized field key 'shipping_credential_kr' for country South Korea. - """ - SHIPPING_CREDENTIAL_KR - - """ - Localized field key 'shipping_credential_mx' for country Mexico. - """ - SHIPPING_CREDENTIAL_MX - - """ - Localized field key 'shipping_credential_my' for country Malaysia. - """ - SHIPPING_CREDENTIAL_MY - - """ - Localized field key 'shipping_credential_pe' for country Peru. - """ - SHIPPING_CREDENTIAL_PE - - """ - Localized field key 'shipping_credential_pt' for country Portugal. - """ - SHIPPING_CREDENTIAL_PT - - """ - Localized field key 'shipping_credential_py' for country Paraguay. - """ - SHIPPING_CREDENTIAL_PY - - """ - Localized field key 'shipping_credential_tr' for country Turkey. - """ - SHIPPING_CREDENTIAL_TR - - """ - Localized field key 'shipping_credential_tw' for country Taiwan. - """ - SHIPPING_CREDENTIAL_TW - - """ - Localized field key 'shipping_credential_type_co' for country Colombia. - """ - SHIPPING_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_br' for country Brazil. - """ - TAX_CREDENTIAL_BR - - """ - Localized field key 'tax_credential_cl' for country Chile. - """ - TAX_CREDENTIAL_CL - - """ - Localized field key 'tax_credential_co' for country Colombia. - """ - TAX_CREDENTIAL_CO - - """ - Localized field key 'tax_credential_cr' for country Costa Rica. - """ - TAX_CREDENTIAL_CR - - """ - Localized field key 'tax_credential_ec' for country Ecuador. - """ - TAX_CREDENTIAL_EC - - """ - Localized field key 'tax_credential_es' for country Spain. - """ - TAX_CREDENTIAL_ES - - """ - Localized field key 'tax_credential_gt' for country Guatemala. - """ - TAX_CREDENTIAL_GT - - """ - Localized field key 'tax_credential_id' for country Indonesia. - """ - TAX_CREDENTIAL_ID - - """ - Localized field key 'tax_credential_it' for country Italy. - """ - TAX_CREDENTIAL_IT - - """ - Localized field key 'tax_credential_mx' for country Mexico. - """ - TAX_CREDENTIAL_MX - - """ - Localized field key 'tax_credential_my' for country Malaysia. - """ - TAX_CREDENTIAL_MY - - """ - Localized field key 'tax_credential_pe' for country Peru. - """ - TAX_CREDENTIAL_PE - - """ - Localized field key 'tax_credential_pt' for country Portugal. - """ - TAX_CREDENTIAL_PT - - """ - Localized field key 'tax_credential_py' for country Paraguay. - """ - TAX_CREDENTIAL_PY - - """ - Localized field key 'tax_credential_tr' for country Turkey. - """ - TAX_CREDENTIAL_TR - - """ - Localized field key 'tax_credential_type_co' for country Colombia. - """ - TAX_CREDENTIAL_TYPE_CO - - """ - Localized field key 'tax_credential_type_mx' for country Mexico. - """ - TAX_CREDENTIAL_TYPE_MX - - """ - Localized field key 'tax_credential_use_mx' for country Mexico. - """ - TAX_CREDENTIAL_USE_MX - - """ - Localized field key 'tax_email_it' for country Italy. - """ - TAX_EMAIL_IT -} - -""" -Represents a mailing address. -""" -type MailingAddress { - """ - The first line of the address. Typically the street address or PO Box number. - """ - address1: String - - """ - The second line of the address. Typically the number of the apartment, suite, or unit. - """ - address2: String - - """ - The name of the city, district, village, or town. - """ - city: String - - """ - The name of the customer's company or organization. - """ - company: String - - """ - The two-letter code for the country of the address. For example, US. - """ - countryCode: CountryCode - - """ - The first name of the customer. - """ - firstName: String - - """ - The last name of the customer. - """ - lastName: String - - """ - The approximate latitude of the address. - """ - latitude: Float - - """ - The approximate longitude of the address. - """ - longitude: Float - - """ - The market of the address. - """ - market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") - - """ - The full name of the customer, based on firstName and lastName. - """ - name: String - - """ - A unique phone number for the customer. Formatted using E.164 standard. For example, +16135551111. - """ - phone: String - - """ - The alphanumeric code for the region. For example, ON. - """ - provinceCode: String - - """ - The zip or postal code of the address. - """ - zip: String -} - -""" -A market is a group of one or more regions that you want to target for international sales. -By creating a market, you can configure a distinct, localized shopping experience for -customers from a specific area of the world. For example, you can -[change currency](https://shopify.dev/api/admin-graphql/current/mutations/marketCurrencySettingsUpdate), -[configure international pricing](https://shopify.dev/api/examples/product-price-lists), -or [add market-specific domains or subfolders](https://shopify.dev/api/admin-graphql/current/objects/MarketWebPresence). -""" -type Market implements HasMetafields { - """ - A human-readable unique string for the market automatically generated from its title. - """ - handle: Handle! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - A geographic region which comprises a market. - """ - regions: [MarketRegion!]! -} - -""" -Represents a region. -""" -interface MarketRegion { - """ - The name of the region in the language of the current localization. - """ - name: String -} - -""" -A country which comprises a market. -""" -type MarketRegionCountry implements MarketRegion { - """ - The two-letter code for the country. - """ - code: CountryCode! - - """ - The country name in the language of the current localization. - """ - name: String! -} - -""" -The merchandise to be purchased at checkout. -""" -union Merchandise = CustomProduct | ProductVariant - -""" -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). -""" -type Metafield { - """ - The data stored in the metafield in JSON format. - """ - jsonValue: JSON! - - """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). - """ - type: String! - - """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. - """ - value: String! -} - -""" -A monetary value with currency. -""" -type MoneyV2 { - """ - Decimal money amount. - """ - amount: Decimal! - - """ - Currency of the money. - """ - currencyCode: CurrencyCode! -} - -""" -The root mutation for the API. -""" -type MutationRoot { - """ - Handles the Function result for the cart.delivery-options.discounts.generate.fetch target. - """ - cartDeliveryOptionsDiscountsGenerateFetch( - """ - The result of the Function. - """ - result: CartDeliveryOptionsDiscountsGenerateFetchResult! - ): Void! - - """ - Handles the Function result for the cart.delivery-options.discounts.generate.run target. - """ - cartDeliveryOptionsDiscountsGenerateRun( - """ - The result of the Function. - """ - result: CartDeliveryOptionsDiscountsGenerateRunResult! - ): Void! - - """ - Handles the Function result for the cart.lines.discounts.generate.fetch target. - """ - cartLinesDiscountsGenerateFetch( - """ - The result of the Function. - """ - result: CartLinesDiscountsGenerateFetchResult! - ): Void! - - """ - Handles the Function result for the cart.lines.discounts.generate.run target. - """ - cartLinesDiscountsGenerateRun( - """ - The result of the Function. - """ - result: CartLinesDiscountsGenerateRunResult! - ): Void! -} - -""" -The order discount candidate to be applied. -""" -input OrderDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The conditions that must be satisfied to apply the order discount candidate. - """ - conditions: [Condition!] - - """ - The discount message. - """ - message: String - - """ - The targets of the order discount candidate. - """ - targets: [OrderDiscountCandidateTarget!]! - - """ - The value of the order discount candidate. - """ - value: OrderDiscountCandidateValue! -} - -""" -A target of a order discount candidate. -""" -input OrderDiscountCandidateTarget @oneOf { - """ - If used, the discount targets the entire order subtotal after product discounts are applied. - """ - orderSubtotal: OrderSubtotalTarget -} - -""" -The order discount candidate value. -""" -input OrderDiscountCandidateValue @oneOf { - """ - A fixed amount value. - """ - fixedAmount: FixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of order discount candidates. -""" -enum OrderDiscountSelectionStrategy { - """ - Only apply the first order discount candidate with conditions that are satisfied. - """ - FIRST - - """ - Only apply the order discount candidate that offers the maximum reduction. - """ - MAXIMUM -} - -""" -An operation that applies order discounts to a cart that share a selection strategy. -""" -input OrderDiscountsAddOperation { - """ - The list of order discount candidates to be applied. - """ - candidates: [OrderDiscountCandidate!]! - - """ - The strategy that's applied to the list of discounts. - """ - selectionStrategy: OrderDiscountSelectionStrategy! -} - -""" -The condition for checking the minimum subtotal amount of the order. -""" -input OrderMinimumSubtotal { - """ - Cart line IDs with a merchandise line price that's excluded to calculate the minimum subtotal amount of the order. - """ - excludedCartLineIds: [ID!]! - - """ - The minimum subtotal amount of the order. - """ - minimumAmount: Decimal! -} - -""" -If used, the discount targets the entire order subtotal after product discounts are applied. -""" -input OrderSubtotalTarget { - """ - The list of excluded cart line IDs. These cart lines are excluded from the order - subtotal calculation when calculating the maximum value of the discount. - """ - excludedCartLineIds: [ID!]! -} - -""" -A percentage value. -""" -input Percentage { - """ - The percentage value. - - The value is validated against: >= 0 and <= 100. - """ - value: Decimal! -} - -""" -Represents a product. -""" -type Product implements HasGates & HasMetafields { - """ - Returns active gate subjects bound to the resource. - """ - gates( - """ - The handle of the gate configurations to search for. - """ - handle: Handle - ): [GateSubject!]! @deprecated(reason: "Gates API is being sunset and will be removed in a future version. Use `metafields` instead for gate configuration.") - - """ - A unique human-friendly string of the product's title. - """ - handle: Handle! - - """ - Whether the product has any of the given tags. - """ - hasAnyTag( - """ - The tags to check. - """ - tags: [String!]! = [] - ): Boolean! - - """ - Whether the product has the given tags. - """ - hasTags( - """ - The tags to check. - """ - tags: [String!]! = [] - ): [HasTagResponse!]! - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Whether the product is in any of the given collections. - """ - inAnyCollection( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): Boolean! - - """ - Whether the product is in the given collections. - """ - inCollections( - """ - The IDs of the collections to check. - """ - ids: [ID!]! = [] - ): [CollectionMembership!]! - - """ - Whether the product is a gift card. - """ - isGiftCard: Boolean! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product type specified by the merchant. - """ - productType: String - - """ - The localized title of the product in the customer’s locale. - """ - title: String! - - """ - The name of the product's vendor. - """ - vendor: String -} - -""" -The product discount candidate to be applied. -""" -input ProductDiscountCandidate { - """ - The discount code associated with this discount candidate, for code-based discounts. - """ - associatedDiscountCode: AssociatedDiscountCode - - """ - The discount message. - """ - message: String - - """ - The targets of the product discount candidate. - """ - targets: [ProductDiscountCandidateTarget!]! - - """ - The value of the product discount candidate. - """ - value: ProductDiscountCandidateValue! -} - -""" -A product discount candidate fixed amount value. -""" -input ProductDiscountCandidateFixedAmount { - """ - The fixed amount value of the product discount candidate, in the currency of the cart. - - The amount must be greater than or equal to 0. - """ - amount: Decimal! - - """ - Whether to apply the value to each entitled item. - - The default value is `false`, which causes the value to be applied once across the entitled items. - When the value is `true`, the value will be applied to each of the entitled items. - """ - appliesToEachItem: Boolean = false -} - -""" -A target of a product discount candidate, which determines which cart line(s) the discount will affect. - -Multiple targets with the same type and ID are the same as a single target of that type and ID with their -quantities added together, or `null` if any of those targets have a quantity of `null`. - -See the [Discounts API reference](https://shopify.dev/docs/api/functions/reference/discount/graphql/functioncartrunresult) for examples. -""" -input ProductDiscountCandidateTarget @oneOf { - """ - A discount [Target](https://shopify.dev/api/functions/reference/product-discounts/graphql/common-objects/target) that applies to a specific cart line, up to an optional quantity limit. - """ - cartLine: CartLineTarget -} - -""" -The value of the product discount candidate. -""" -input ProductDiscountCandidateValue @oneOf { - """ - A product discount candidate fixed amount value. - """ - fixedAmount: ProductDiscountCandidateFixedAmount - - """ - A percentage value. - """ - percentage: Percentage -} - -""" -The strategy that's applied to the list of product discount candidates. -""" -enum ProductDiscountSelectionStrategy { - """ - Apply all product discount candidates with conditions that are satisfied. This - does not override discount combination or stacking rules. - """ - ALL - - """ - Only apply the first product discount candidate with conditions that are satisfied. - """ - FIRST - - """ - Only apply the product discount candidate that offers the maximum reduction. - """ - MAXIMUM -} - -""" -An operation that applies product discounts to a cart that share a selection strategy. -""" -input ProductDiscountsAddOperation { - """ - The list of product discount candidates to be applied. - """ - candidates: [ProductDiscountCandidate!]! - - """ - The strategy that's applied to the list of product discount candidates. - """ - selectionStrategy: ProductDiscountSelectionStrategy! -} - -""" -Represents a product variant. -""" -type ProductVariant implements HasMetafields { - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The product that this variant belongs to. - """ - product: Product! - - """ - Whether the merchandise requires shipping. - """ - requiresShipping: Boolean! - - """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. - """ - sku: String - - """ - The localized title of the product variant in the customer’s locale. - """ - title: String - - """ - The weight of the product variant in the unit system specified with `weight_unit`. - """ - weight: Float - - """ - Unit of measurement for weight. - """ - weightUnit: WeightUnit! -} - -""" -Represents information about the buyer that is interacting with the cart. -""" -type PurchasingCompany { - """ - The company associated to the order or draft order. - """ - company: Company! - - """ - The company contact associated to the order or draft order. - """ - contact: CompanyContact - - """ - The company location associated to the order or draft order. - """ - location: CompanyLocation! -} - -""" -Represents how products and variants can be sold and purchased. -""" -type SellingPlan implements HasMetafields { - """ - The description of the selling plan. - """ - description: String - - """ - A globally-unique identifier. - """ - id: ID! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield - - """ - The name of the selling plan. For example, '6 weeks of prepaid granola, delivered weekly'. - """ - name: String! - - """ - Whether purchasing the selling plan will result in multiple deliveries. - """ - recurringDeliveries: Boolean! -} - -""" -Represents an association between a variant and a selling plan. Selling plan -allocations describe the options offered for each variant, and the price of the -variant when purchased with a selling plan. -""" -type SellingPlanAllocation { - """ - A list of price adjustments, with a maximum of two. When there are two, the - first price adjustment goes into effect at the time of purchase, while the - second one starts after a certain number of orders. A price adjustment - represents how a selling plan affects pricing when a variant is purchased with - a selling plan. Prices display in the customer's currency if the shop is - configured for it. - """ - priceAdjustments: [SellingPlanAllocationPriceAdjustment!]! - - """ - A representation of how products and variants can be sold and purchased. For - example, an individual selling plan could be '6 weeks of prepaid granola, - delivered weekly'. - """ - sellingPlan: SellingPlan! -} - -""" -The resulting prices for variants when they're purchased with a specific selling plan. -""" -type SellingPlanAllocationPriceAdjustment { - """ - The effective price for a single delivery. For example, for a prepaid - subscription plan that includes 6 deliveries at the price of $48.00, the per - delivery price is $8.00. - """ - perDeliveryPrice: MoneyV2! - - """ - The price of the variant when it's purchased with a selling plan For example, - for a prepaid subscription plan that includes 6 deliveries of $10.00 granola, - where the customer gets 20% off, the price is 6 x $10.00 x 0.80 = $48.00. - """ - price: MoneyV2! -} - -""" -Information about the shop. -""" -type Shop implements HasMetafields { - """ - Information about the current time relative to the shop's timezone setting. - """ - localTime: LocalTime! - - """ - Returns a metafield by namespace and key that belongs to the resource. - """ - metafield( - """ - The key for the metafield. - """ - key: String! - - """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. - """ - namespace: String - ): Metafield -} - -""" -A subset of the [ISO 8601](https://en.wikipedia.org/wiki/ISO_8601) format that -includes the time but not the date or timezone which is determined from context. -For example, "05:43:21". -""" -scalar TimeWithoutTimezone - -""" -Represents an [RFC 3986](https://datatracker.ietf.org/doc/html/rfc3986) and -[RFC 3987](https://datatracker.ietf.org/doc/html/rfc3987)-compliant URI string. - -For example, `"https://example.myshopify.com"` is a valid URL. It includes a scheme (`https`) and a host -(`example.myshopify.com`). -""" -scalar URL - -""" -A void type that can be used to return a null value from a mutation. -""" -scalar Void - -""" -Units of measurement for weight. -""" -enum WeightUnit { - """ - Metric system unit of mass. - """ - GRAMS - - """ - 1 kilogram equals 1000 grams. - """ - KILOGRAMS - - """ - Imperial system unit of mass. - """ - OUNCES - - """ - 1 pound equals 16 ounces. - """ - POUNDS -} diff --git a/discounts/rust/network/default/shopify.extension.toml.liquid b/discounts/rust/network/default/shopify.extension.toml.liquid deleted file mode 100644 index 3a657001..00000000 --- a/discounts/rust/network/default/shopify.extension.toml.liquid +++ /dev/null @@ -1,33 +0,0 @@ -api_version = "unstable" - -[[extensions]] -name = "t:name" -handle = "{{handle | replace: " ", "-" | downcase}}" -type = "function" -{% if uid %}uid = "{{ uid }}"{% endif %} -description = "t:description" - - [[extensions.targeting]] - target = "cart.lines.discounts.generate.run" - input_query = "src/generate_cart_run.graphql" - export = "generate_cart_run" - - [[extensions.targeting]] - target = "cart.delivery-options.discounts.generate.run" - input_query = "src/generate_delivery_run.graphql" - export = "generate_delivery_run" - - [[extensions.targeting]] - target = "cart.lines.discounts.generate.fetch" - input_query = "src/generate_cart_fetch.graphql" - export = "generate_cart_fetch" - - [[extensions.targeting]] - target = "cart.delivery-options.discounts.generate.fetch" - input_query = "src/generate_delivery_fetch.graphql" - export = "generate_delivery_fetch" - - [extensions.build] - command = "cargo build --target=wasm32-wasip1 --release" - path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" - watch = [ "src/**/*.rs" ] diff --git a/discounts/rust/network/default/src/generate_cart_fetch.graphql.liquid b/discounts/rust/network/default/src/generate_cart_fetch.graphql.liquid deleted file mode 100644 index 890973d8..00000000 --- a/discounts/rust/network/default/src/generate_cart_fetch.graphql.liquid +++ /dev/null @@ -1,3 +0,0 @@ -query Input { - enteredDiscountCodes -} diff --git a/discounts/rust/network/default/src/generate_cart_fetch.rs b/discounts/rust/network/default/src/generate_cart_fetch.rs deleted file mode 100644 index b1ce3ca5..00000000 --- a/discounts/rust/network/default/src/generate_cart_fetch.rs +++ /dev/null @@ -1,91 +0,0 @@ -use serde_json::json; -use shopify_function; -use shopify_function::prelude::*; - -use cart_lines_discounts_generate_fetch::input::ResponseData as CartFetchResponseData; -use cart_lines_discounts_generate_fetch::output::{ - CartLinesDiscountsGenerateFetchResult, HttpRequest as CartFetchHttpRequest, - HttpRequestHeader as CartFetchHttpRequestHeader, - HttpRequestMethod as CartFetchHttpRequestMethod, - HttpRequestPolicy as CartFetchHttpRequestPolicy, -}; - -#[shopify_function_target( - query_path = "src/generate_cart_fetch.graphql", - schema_path = "schema.graphql", - target = "cartLinesDiscountsGenerateFetch" -)] -fn generate_cart_fetch( - input: CartFetchResponseData, -) -> shopify_function::Result { - let entered_discount_codes = &input.entered_discount_codes; - let json_body = json!({ "enteredDiscountCodes": entered_discount_codes }); - - let request = CartFetchHttpRequest { - headers: vec![ - CartFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }, - CartFetchHttpRequestHeader { - name: "Content-Type".to_string(), - value: "application/json".to_string(), - }, - ], - method: CartFetchHttpRequestMethod::POST, - policy: CartFetchHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "".to_string(), - body: Some(json_body.to_string()), - json_body: Some(json_body.clone()), - }; - - Ok(CartLinesDiscountsGenerateFetchResult { - request: Some(request), - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use cart_lines_discounts_generate_fetch::output::{ - CartLinesDiscountsGenerateFetchResult, HttpRequest as CartFetchHttpRequest, - HttpRequestHeader as CartFetchHttpRequestHeader, - HttpRequestMethod as CartFetchHttpRequestMethod, - HttpRequestPolicy as CartFetchHttpRequestPolicy, - }; - use shopify_function::{run_function_with_input, Result}; - - #[test] - fn adds_entered_discount_codes_to_json_body_for_cart() -> Result<()> { - let input = json!({"enteredDiscountCodes": []}).to_string(); - - let result = run_function_with_input(generate_cart_fetch, &input)?; - let json_body = json!({ "enteredDiscountCodes": [] }); - let expected = CartLinesDiscountsGenerateFetchResult { - request: Some(CartFetchHttpRequest { - headers: vec![ - CartFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }, - CartFetchHttpRequestHeader { - name: "Content-Type".to_string(), - value: "application/json".to_string(), - }, - ], - method: CartFetchHttpRequestMethod::POST, - policy: CartFetchHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "".to_string(), - json_body: Some(json_body.clone()), - body: Some(json_body.to_string()), - }), - }; - - assert_eq!(result, expected); - Ok(()) - } -} diff --git a/discounts/rust/network/default/src/generate_cart_run.graphql.liquid b/discounts/rust/network/default/src/generate_cart_run.graphql.liquid deleted file mode 100644 index 005ae400..00000000 --- a/discounts/rust/network/default/src/generate_cart_run.graphql.liquid +++ /dev/null @@ -1,17 +0,0 @@ -query Input { - fetchResult { - jsonBody - status - } - cart { - lines { - id - cost { - subtotalAmount { - amount - } - } - } - } -} - diff --git a/discounts/rust/network/default/src/generate_cart_run.rs b/discounts/rust/network/default/src/generate_cart_run.rs deleted file mode 100644 index 1852446d..00000000 --- a/discounts/rust/network/default/src/generate_cart_run.rs +++ /dev/null @@ -1,67 +0,0 @@ -use serde::Deserialize; -use shopify_function::prelude::*; -use shopify_function::Result; - -use cart_lines_discounts_generate_run::output::{ - CartLinesDiscountsGenerateRunResult, CartOperation, EnteredDiscountCodesAcceptOperation, - OrderDiscountsAddOperation, ProductDiscountsAddOperation, -}; - -use cart_lines_discounts_generate_run::input::ResponseData; - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct OperationItem { - #[serde(default)] - product_discounts_add: Option, - #[serde(default)] - order_discounts_add: Option, - #[serde(default)] - entered_discount_codes_accept: Option, - // Ignore other operation types that might be in the response but we don't use in cart context - #[serde(flatten)] - _other: std::collections::HashMap, -} - -#[shopify_function_target( - target = "cartLinesDiscountsGenerateRun", - query_path = "src/generate_cart_run.graphql", - schema_path = "schema.graphql" -)] -fn generate_cart_run(input: ResponseData) -> Result { - let fetch_result = input.fetch_result.ok_or("Missing fetch result")?; - - // Use jsonBody which is the only available property - let json_body = fetch_result - .json_body - .ok_or("Missing json_body in response")?; - - // Parse using the JSON value - let operation_items = serde_json::from_value::>(json_body) - .map_err(|e| format!("Failed to convert jsonBody: {}", e))?; - - // Convert the response into operations - let mut operations = Vec::new(); - - // Process each operation item - for item in operation_items { - if let Some(validations) = item.entered_discount_codes_accept { - operations.push(CartOperation::EnteredDiscountCodesAccept(validations)); - } - - if let Some(product_discounts_add_operation) = item.product_discounts_add { - operations.push(CartOperation::ProductDiscountsAdd( - product_discounts_add_operation, - )); - } - - if let Some(order_discounts_add_operation) = item.order_discounts_add { - operations.push(CartOperation::OrderDiscountsAdd( - order_discounts_add_operation, - )); - } - // Ignore delivery discounts for cart operations - } - - Ok(CartLinesDiscountsGenerateRunResult { operations }) -} diff --git a/discounts/rust/network/default/src/generate_delivery_fetch.graphql.liquid b/discounts/rust/network/default/src/generate_delivery_fetch.graphql.liquid deleted file mode 100644 index 890973d8..00000000 --- a/discounts/rust/network/default/src/generate_delivery_fetch.graphql.liquid +++ /dev/null @@ -1,3 +0,0 @@ -query Input { - enteredDiscountCodes -} diff --git a/discounts/rust/network/default/src/generate_delivery_fetch.rs b/discounts/rust/network/default/src/generate_delivery_fetch.rs deleted file mode 100644 index 741c723f..00000000 --- a/discounts/rust/network/default/src/generate_delivery_fetch.rs +++ /dev/null @@ -1,91 +0,0 @@ -use serde_json::json; -use shopify_function; -use shopify_function::prelude::*; - -use cart_delivery_options_discounts_generate_fetch::input::ResponseData as DeliveryFetchResponseData; -use cart_delivery_options_discounts_generate_fetch::output::{ - CartDeliveryOptionsDiscountsGenerateFetchResult, HttpRequest as DeliveryFetchHttpRequest, - HttpRequestHeader as DeliveryFetchHttpRequestHeader, - HttpRequestMethod as DeliveryFetchHttpRequestMethod, - HttpRequestPolicy as DeliveryFetchHttpRequestPolicy, -}; - -#[shopify_function_target( - query_path = "src/generate_delivery_fetch.graphql", - schema_path = "schema.graphql", - target = "cartDeliveryOptionsDiscountsGenerateFetch" -)] -fn generate_delivery_fetch( - input: DeliveryFetchResponseData, -) -> shopify_function::Result { - let entered_discount_codes = &input.entered_discount_codes; - let json_body = json!({ "enteredDiscountCodes": entered_discount_codes }); - - let request = DeliveryFetchHttpRequest { - headers: vec![ - DeliveryFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }, - DeliveryFetchHttpRequestHeader { - name: "Content-Type".to_string(), - value: "application/json".to_string(), - }, - ], - method: DeliveryFetchHttpRequestMethod::POST, - policy: DeliveryFetchHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "".to_string(), - body: Some(json_body.to_string()), - json_body: Some(json_body.clone()), - }; - - Ok(CartDeliveryOptionsDiscountsGenerateFetchResult { - request: Some(request), - }) -} - -#[cfg(test)] -mod tests { - use super::*; - use cart_delivery_options_discounts_generate_fetch::output::{ - CartDeliveryOptionsDiscountsGenerateFetchResult, HttpRequest as DeliveryFetchHttpRequest, - HttpRequestHeader as DeliveryFetchHttpRequestHeader, - HttpRequestMethod as DeliveryFetchHttpRequestMethod, - HttpRequestPolicy as DeliveryFetchHttpRequestPolicy, - }; - use shopify_function::{run_function_with_input, Result}; - - #[test] - fn adds_entered_discount_codes_to_body_for_delivery() -> Result<()> { - let input = json!({ "enteredDiscountCodes": ["ABC"] }).to_string(); - - let result = run_function_with_input(generate_delivery_fetch, &input)?; - let json_body = json!({ "enteredDiscountCodes": ["ABC"] }); - let expected = CartDeliveryOptionsDiscountsGenerateFetchResult { - request: Some(DeliveryFetchHttpRequest { - headers: vec![ - DeliveryFetchHttpRequestHeader { - name: "accept".to_string(), - value: "application/json".to_string(), - }, - DeliveryFetchHttpRequestHeader { - name: "Content-Type".to_string(), - value: "application/json".to_string(), - }, - ], - method: DeliveryFetchHttpRequestMethod::POST, - policy: DeliveryFetchHttpRequestPolicy { - read_timeout_ms: 2000, - }, - url: "".to_string(), - json_body: Some(json_body.clone()), - body: Some(json_body.to_string()), - }), - }; - - assert_eq!(result, expected); - Ok(()) - } -} diff --git a/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid b/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid deleted file mode 100644 index 2b73d7d8..00000000 --- a/discounts/rust/network/default/src/generate_delivery_run.graphql.liquid +++ /dev/null @@ -1,11 +0,0 @@ -query Input { - fetchResult { - jsonBody - status - } - cart { - deliveryGroups { - id - } - } -} diff --git a/discounts/rust/network/default/src/generate_delivery_run.rs b/discounts/rust/network/default/src/generate_delivery_run.rs deleted file mode 100644 index c7415e57..00000000 --- a/discounts/rust/network/default/src/generate_delivery_run.rs +++ /dev/null @@ -1,61 +0,0 @@ -use serde::Deserialize; -use shopify_function::prelude::*; -use shopify_function::Result; - -use cart_delivery_options_discounts_generate_run::output::{ - CartDeliveryOptionsDiscountsGenerateRunResult, DeliveryDiscountsAddOperation, - DeliveryOperation, EnteredDiscountCodesAcceptOperation, -}; - -use cart_delivery_options_discounts_generate_run::input::ResponseData; - -#[derive(Deserialize)] -#[serde(rename_all = "camelCase")] -struct OperationItem { - #[serde(default)] - delivery_discounts_add: Option, - #[serde(default)] - entered_discount_codes_accept: Option, - // Ignore any other fields we don't need - #[serde(flatten)] - _other: std::collections::HashMap, -} - -#[shopify_function_target( - target = "cartDeliveryOptionsDiscountsGenerateRun", - query_path = "src/generate_delivery_run.graphql", - schema_path = "schema.graphql" -)] -fn generate_delivery_run( - input: ResponseData, -) -> Result { - let fetch_result = input.fetch_result.ok_or("Missing fetch result")?; - - // Use jsonBody which is the only available property - let json_body = fetch_result - .json_body - .ok_or("Missing json_body in response")?; - - // Parse using the JSON value - let operation_items = serde_json::from_value::>(json_body) - .map_err(|e| format!("Failed to convert jsonBody: {}", e))?; - - // Convert the response into operations - let mut operations = Vec::new(); - - // Process each operation item - for item in operation_items { - if let Some(validations) = item.entered_discount_codes_accept { - operations.push(DeliveryOperation::EnteredDiscountCodesAccept(validations)); - } - - if let Some(delivery_discounts_add_operation) = item.delivery_discounts_add { - operations.push(DeliveryOperation::DeliveryDiscountsAdd( - delivery_discounts_add_operation, - )); - } - // Ignore cart/order discounts for delivery operations - } - - Ok(CartDeliveryOptionsDiscountsGenerateRunResult { operations }) -} diff --git a/discounts/rust/network/default/src/main.rs b/discounts/rust/network/default/src/main.rs deleted file mode 100644 index e3dc67e8..00000000 --- a/discounts/rust/network/default/src/main.rs +++ /dev/null @@ -1,10 +0,0 @@ -use std::process; -pub mod generate_cart_fetch; -pub mod generate_cart_run; -pub mod generate_delivery_fetch; -pub mod generate_delivery_run; - -fn main() { - eprintln!("Please invoke a named export."); - process::exit(1); -} From 20e149ce2a47a56768044eda49b7a42b17460cbb Mon Sep 17 00:00:00 2001 From: Martin Gingras Date: Wed, 7 May 2025 10:48:05 -0400 Subject: [PATCH 3/3] Update Validation function templates --- .../default/schema.graphql | 763 +++++++++++++----- .../default/shopify.extension.toml.liquid | 5 +- .../default/src/run.liquid | 44 +- .../default/src/run.test.liquid | 65 +- .../default/schema.graphql | 763 +++++++++++++----- .../default/shopify.extension.toml.liquid | 5 +- .../default/src/run.rs | 31 +- .../default/schema.graphql | 763 +++++++++++++----- .../default/shopify.extension.toml.liquid | 5 +- 9 files changed, 1760 insertions(+), 684 deletions(-) diff --git a/checkout/javascript/cart-checkout-validation/default/schema.graphql b/checkout/javascript/cart-checkout-validation/default/schema.graphql index 705a319e..27148a73 100644 --- a/checkout/javascript/cart-checkout-validation/default/schema.graphql +++ b/checkout/javascript/cart-checkout-validation/default/schema.graphql @@ -14,11 +14,22 @@ Scale the Functions resource limits based on the field's length. directive @scaleLimits(rate: Float!) on FIELD_DEFINITION """ -Represents a generic custom attribute, such as whether an order is a customer's first. +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +A custom property. Attributes are used to store additional information about a Shopify resource, such as +products, customers, or orders. Attributes are stored as key-value pairs. + +For example, a list of attributes might include whether a customer is a first-time buyer (`"customer_first_order": "true"`), +whether an order is gift-wrapped (`"gift_wrapped": "true"`), a preferred delivery date +(`"preferred_delivery_date": "2025-10-01"`), the discount applied (`"loyalty_discount_applied": "10%"`), and any +notes provided by the customer (`"customer_notes": "Please leave at the front door"`). """ type Attribute { """ - The key or name of the attribute. For example, `"customersFirstOrder"`. + The key or name of the attribute. For example, `"customer_first_order"`. """ key: String! @@ -29,31 +40,39 @@ type Attribute { } """ -Represents information about the buyer that is interacting with the cart. +Information about the customer that's interacting with the cart. It includes details such as the +customer's email and phone number, and the total amount of money the customer has spent in the store. +This information helps personalize the checkout experience and ensures that accurate pricing and delivery options +are displayed to customers. """ type BuyerIdentity { """ - The customer associated with the cart. + The customer that's interacting with the cart. A customer is a buyer who has an + [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. """ customer: Customer """ - The email address of the buyer that's interacting with the cart. + The email address of the customer that's interacting with the cart. """ email: String """ - Whether the buyer authenticated with a customer account. + Whether the customer is authenticated through their + [customer account](https://help.shopify.com/manual/customers/customer-accounts). + If the customer is authenticated, then the `customer` field returns the customer's information. + If the customer isn't authenticated, then the `customer` field returns `null`. """ isAuthenticated: Boolean! """ - The phone number of the buyer that's interacting with the cart. + The phone number of the customer that's interacting with the cart. """ phone: String """ - The purchasing company associated with the cart. + The company of a B2B customer that's interacting with the cart. + Used to manage and track purchases made by businesses rather than individual customers. """ purchasingCompany: PurchasingCompany } @@ -83,46 +102,59 @@ enum BuyerJourneyStep { } """ -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase +and information about the customer, such as the customer's email address and phone number. """ type Cart { """ - The attributes associated with the cart. Attributes are represented as key-value pairs. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - Information about the buyer that is interacting with the cart. + Information about the customer that's interacting with the cart. It includes details such as the + customer's email and phone number, and the total amount of money the customer has spent in the store. + This information helps personalize the checkout experience and ensures that accurate pricing and delivery options + are displayed to customers. """ buyerIdentity: BuyerIdentity """ - The costs that the buyer will pay at checkout. + A breakdown of the costs that the customer will pay at checkout. It includes the total amount, + the subtotal before taxes and duties, the tax amount, and duty charges. """ cost: CartCost! """ - A list of lines containing information about the items that can be delivered. + The items in a cart that are eligible for fulfillment and can be delivered to the customer. """ deliverableLines: [DeliverableCartLine!]! """ - The delivery groups available for the cart based on the buyer's shipping address. + A collection of items that are grouped by shared delivery characteristics. Delivery groups streamline + fulfillment by organizing items that can be shipped together, based on the customer's + shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped + together, then the items are included in the same delivery group. """ deliveryGroups: [CartDeliveryGroup!]! """ - A list of lines containing information about the items the customer intends to purchase. + The items in a cart that the customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ lines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The localized fields available for the cart. + The additional fields on the **Cart** page that are required for international orders in specific countries, + such as customs information or tax identification numbers. """ localizedFields( """ @@ -133,113 +165,140 @@ type Cart { } """ -The cost that the buyer will pay at checkout. +A breakdown of the costs that the customer will pay at checkout. It includes the total amount, +the subtotal before taxes and duties, the tax amount, and duty charges. """ type CartCost { """ - The amount, before taxes and discounts, for the customer to pay. + The amount for the customer to pay at checkout, excluding taxes and discounts. """ subtotalAmount: MoneyV2! """ - The total amount for the customer to pay. + The total amount for the customer to pay at checkout. """ totalAmount: MoneyV2! """ - The duty amount for the customer to pay at checkout. + The duty charges for a customer to pay at checkout. """ totalDutyAmount: MoneyV2 """ - The tax amount for the customer to pay at checkout. + The total tax amount for the customer to pay at checkout. """ totalTaxAmount: MoneyV2 } """ -Information about the options available for one or more line items to be delivered to a specific address. +Information about items in a cart that are grouped by shared delivery characteristics. +Delivery groups streamline fulfillment by organizing items that can be shipped together, based on the customer's +shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped +together, then the items are included in the same delivery group. """ type CartDeliveryGroup { """ - A list of cart lines for the delivery group. + Information about items in a cart that a customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ cartLines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The destination address for the delivery group. + The shipping or destination address associated with the delivery group. """ deliveryAddress: MailingAddress """ - The delivery options available for the delivery group. + The delivery options available for the delivery group. Delivery options are the different ways that customers + can choose to have their orders shipped. Examples include express shipping or standard shipping. """ deliveryOptions: [CartDeliveryOption!]! """ - Unique identifier for the delivery group. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the delivery group. """ id: ID! """ - Information about the delivery option the buyer has selected. + Information about the delivery option that the customer has selected. """ selectedDeliveryOption: CartDeliveryOption } """ -Information about a delivery option. +Information about a delivery option that's available for an item in a cart. Delivery options are the different +ways that customers can choose to have their orders shipped. Examples include express shipping or standard +shipping. """ type CartDeliveryOption { """ - The code of the delivery option. + A unique identifier that represents the delivery option offered to customers. + For example, `Canada Post Expedited`. """ code: String """ - The cost for the delivery option. + The amount that the customer pays if they select the delivery option. """ cost: MoneyV2! """ - The method for the delivery option. + The delivery method associated with the delivery option. A delivery method is a way that merchants can + fulfill orders from their online stores. Delivery methods include shipping to an address, + [local pickup](https://help.shopify.com/manual/fulfillment/setup/delivery-methods/pickup-in-store), + and shipping to a [pickup point](https://help.shopify.com/manual/fulfillment/shopify-shipping/pickup-points), + all of which are natively supported by Shopify checkout. """ deliveryMethodType: DeliveryMethod! """ - The description of the delivery option. + A single-line description of the delivery option, with HTML tags removed. """ description: String """ - The unique identifier of the delivery option. + A unique, human-readable identifier of the delivery option's title. + A handle can contain letters, hyphens (`-`), and numbers, but not spaces. + For example, `standard-shipping`. """ handle: Handle! """ - The title of the delivery option. + The name of the delivery option that displays to customers. The title is used to construct the delivery + option's handle. For example, if a delivery option is titled "Standard Shipping", then the handle is + `standard-shipping`. """ title: String } """ -Represents information about the merchandise in the cart. +Information about an item in a cart that a customer intends to purchase. A cart line is an entry in the +customer's cart that represents a single unit of a product variant. For example, if a customer adds two +different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - The cost of the merchandise line that the buyer will pay at checkout. + The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's + cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of + the same t-shirt to their cart, then each size is represented as a separate cart line. """ cost: CartLineCost! @@ -249,59 +308,92 @@ type CartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. + The [selling plan](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + associated with the cart line, including information about how a product variant can be sold and purchased. """ sellingPlanAllocation: SellingPlanAllocation } """ -The cost of the merchandise line that the buyer will pay at checkout. +The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's +cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of +the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLineCost { """ - The amount of the merchandise line. + The cost of a single unit. For example, if a customer purchases three units of a product + that are priced at $10 each, then the `amountPerQuantity` is $10. """ amountPerQuantity: MoneyV2! """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. + The cost of a single unit before any discounts are applied. This field is used to calculate and display + savings for customers. For example, if a product's `compareAtAmountPerQuantity` is $25 and its current price + is $20, then the customer sees a $5 discount. This value can change based on the buyer's identity and is + `null` when the value is hidden from buyers. """ compareAtAmountPerQuantity: MoneyV2 """ - The cost of the merchandise line before line-level discounts. + The cost of items in the cart before applying any discounts to certain items. + This amount serves as the starting point for calculating any potential savings customers + might receive through promotions or discounts. """ subtotalAmount: MoneyV2! """ - The total cost of the merchandise line. + The total cost of items in a cart. """ totalAmount: MoneyV2! } """ -Represents whether the product is a member of the given collection. +The fetch target result. Your Function must return this data structure when generating the request. +""" +input CartValidationsGenerateFetchResult { + """ + The attributes associated with an HTTP request. + """ + request: HttpRequest +} + +""" +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. +""" +input CartValidationsGenerateRunResult { + """ + The ordered list of operations to apply. + """ + operations: [Operation!]! +} + +""" +Whether the product is in the specified collection. + +A collection is a group of products that can be displayed in online stores and other sales channels in +categories, which makes it easy for customers to find them. For example, an athletics store might create +different collections for running attire and accessories. """ type CollectionMembership { """ - The ID of the collection. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the collection. """ collectionId: ID! """ - Whether the product is a member of the collection. + Whether the product is in the specified collection. """ isMember: Boolean! } @@ -326,16 +418,24 @@ type Company implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -409,16 +509,24 @@ type CompanyLocation implements HasMetafields { locale: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -436,7 +544,9 @@ type CompanyLocation implements HasMetafields { } """ -A country. +The country for which the store is customized, reflecting local preferences and regulations. +Localization might influence the language, currency, and product offerings available in a store to enhance +the shopping experience for customers in that region. """ type Country { """ @@ -1679,9 +1789,8 @@ enum CountryCode { } """ -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. +The three-letter currency codes that represent the world currencies used in stores. Currency codes include +[standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, and non-standard codes. """ enum CurrencyCode { """ @@ -2491,7 +2600,10 @@ enum CurrencyCode { } """ -A custom product. +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ type CustomProduct { """ @@ -2500,43 +2612,51 @@ type CustomProduct { isGiftCard: Boolean! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents a customer with the shop. +Represents a [customer](https://help.shopify.com/manual/customers/manage-customers) +who has an [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. +`Customer` returns data including the customer's contact information and order history. """ type Customer implements HasMetafields { """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. + The total amount that the customer has spent on orders. + The amount is converted from the shop's currency to the currency of the cart using a market rate. """ amountSpent: MoneyV2! """ - The customer’s name, email or phone number. + The full name of the customer, based on the values for `firstName` and `lastName`. + If `firstName` and `lastName` aren't specified, then the value is the customer's email address. + If the email address isn't specified, then the value is the customer's phone number. """ displayName: String! """ - The customer’s email address. + The customer's email address. """ email: String @@ -2546,27 +2666,32 @@ type Customer implements HasMetafields { firstName: String """ - Whether the customer has any of the given tags. + Whether the customer is associated with any of the specified tags. The customer must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to search for. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with either the `VIP` or `Gold` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the customer has the given tags. + Whether the customer is associated with the specified tags. The customer must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with both the `VIP` and `Gold` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A unique identifier for the customer. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the customer. """ id: ID! @@ -2576,22 +2701,30 @@ type Customer implements HasMetafields { lastName: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The number of orders made by the customer. + The total number of orders that the customer has made at the store. """ numberOfOrders: Int! } @@ -2629,13 +2762,17 @@ Represents information about the merchandise in the cart. """ type DeliverableCartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute @@ -2646,12 +2783,12 @@ type DeliverableCartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! } @@ -2701,37 +2838,42 @@ input FunctionError { localizedMessage: String! """ - Specifies the path/target for use by the UI. + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. """ target: String! } """ -The fetch target result. Refer to network access for Shopify Functions. +The fetch target result. Your Function must return this data structure when generating the request. """ input FunctionFetchResult { """ - HTTP Request. + The attributes associated with an HTTP request. """ request: HttpRequest } """ -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. In +API versions 2023-10 and beyond, this type is deprecated in favor of +`FunctionRunResult`. """ input FunctionResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } """ -The run target result. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. """ input FunctionRunResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } @@ -2748,32 +2890,42 @@ Represents information about the metafields associated to the specified resource """ interface HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } """ -Represents whether the current object has the given tag. +Whether a Shopify resource, such as a product or customer, has a specified tag. """ type HasTagResponse { """ - Whether the current object has the tag. + Whether the Shopify resource has the tag. """ hasTag: Boolean! """ - The tag. + A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, + a merchant might apply the `sports` and `summer` tags to products that are associated with sportswear for + summer. """ tag: String! } @@ -2886,9 +3038,9 @@ type HttpResponse { headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. + The HTTP response body parsed as JSON. + If the body is valid JSON, it will be parsed and returned as a JSON object. + If parsing fails, then raw body is returned as a string. Use this field when you expect the response to be JSON, or when you're dealing with mixed response types, meaning both JSON and non-JSON. Using this field reduces function instruction consumption and ensures that the data is formatted in logs. @@ -2926,39 +3078,63 @@ Example value: `"gid://shopify/Product/10079785100"` """ scalar ID +""" +The `Input` object is the complete GraphQL schema that your Function can receive +as input to validate cart and checkout. Your Function receives only the fields +that you request in the input query. To optimize performance, we highly +recommend that you request only the fields that your Function requires. +""" type Input { """ - The buyer journey step. + Information about the current step in the buyer's purchasing process. The + buyer journey helps you determine where the customer is in their shopping + experience (for example, cart interaction, checkout interaction, or completing + a checkout). You can use this information to apply appropriate validation + rules based on the customer's current context and create a more tailored and + performant shopping experience. """ buyerJourney: BuyerJourney! """ - The cart. + The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase + and information about the customer, such as the customer's email address and phone number. """ cart: Cart! """ - The result of the fetch target. Refer to network access for Shopify Functions. + The `FunctionFetchResult` object is the result of the fetch target. This is + the response that Shopify returns after executing the HTTP request defined in + your fetch target, and that is passed as input to the run target. For more + information, refer to [network access for Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/network-access). """ - fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run"]) + fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run", "cart.validations.generate.run"]) """ - The localization of the Function execution context. + The regional and language settings that determine how the Function + handles currency, numbers, dates, and other locale-specific values + during discount calculations. These settings are based on the store's configured + [localization practices](https://shopify.dev/docs/apps/build/functions/localization-practices-shopify-functions). """ localization: Localization! """ - The conversion rate between the shop's currency and the currency of the cart. + The exchange rate used to convert discounts between the shop's default + currency and the currency that displays to the customer during checkout. + For example, if a store operates in USD but a customer is viewing discounts in EUR, + then the presentment currency rate handles this conversion for accurate pricing. """ presentmentCurrencyRate: Decimal! """ - Information about the shop. + Information about the shop where the Function is running, including the shop's timezone + setting and associated [metafields](https://shopify.dev/docs/apps/build/custom-data). """ shop: Shop! """ - The validation rule that owns the current function. + The configuration of the app that owns the Function. This configuration + controls how merchants can define validation rules for carts and checkout, + such as inventory checks, price validations, or custom purchase restrictions. """ validation: Validation! } @@ -2981,7 +3157,8 @@ Example value: scalar JSON """ -A language. +The language for which the store is customized, ensuring content is tailored to local customers. +This includes product descriptions and customer communications that resonate with the target audience. """ type Language { """ @@ -3701,7 +3878,8 @@ enum LanguageCode { } """ -Represents limited information about the current time relative to the parent object. +The current time based on the +[store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ type LocalTime { """ @@ -3781,23 +3959,29 @@ type LocalTime { } """ -Information about the localized experiences configured for the shop. +Details about the localized experience for the store in a specific region, including country and language +settings. The localized experience is determined by the store's settings and the customer's location. +Localization ensures that customers can access relevant content and options while browsing or purchasing +products in a store. """ type Localization { """ - The country of the active localized experience. + The country for which the store is customized, reflecting local preferences and regulations. + Localization might influence the language, currency, and product offerings available in a store to enhance + the shopping experience for customers in that region. """ country: Country! """ - The language of the active localized experience. + The language for which the store is customized, ensuring content is tailored to local customers. + This includes product descriptions and customer communications that resonate with the target audience. """ language: Language! """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -3828,187 +4012,187 @@ Unique key identifying localized fields. """ enum LocalizedFieldKey { """ - Localized field key 'shipping_credential_br' for country BR. + Localized field key 'shipping_credential_br' for country Brazil. """ SHIPPING_CREDENTIAL_BR """ - Localized field key 'shipping_credential_cl' for country CL. + Localized field key 'shipping_credential_cl' for country Chile. """ SHIPPING_CREDENTIAL_CL """ - Localized field key 'shipping_credential_cn' for country CN. + Localized field key 'shipping_credential_cn' for country China. """ SHIPPING_CREDENTIAL_CN """ - Localized field key 'shipping_credential_co' for country CO. + Localized field key 'shipping_credential_co' for country Colombia. """ SHIPPING_CREDENTIAL_CO """ - Localized field key 'shipping_credential_cr' for country CR. + Localized field key 'shipping_credential_cr' for country Costa Rica. """ SHIPPING_CREDENTIAL_CR """ - Localized field key 'shipping_credential_ec' for country EC. + Localized field key 'shipping_credential_ec' for country Ecuador. """ SHIPPING_CREDENTIAL_EC """ - Localized field key 'shipping_credential_es' for country ES. + Localized field key 'shipping_credential_es' for country Spain. """ SHIPPING_CREDENTIAL_ES """ - Localized field key 'shipping_credential_gt' for country GT. + Localized field key 'shipping_credential_gt' for country Guatemala. """ SHIPPING_CREDENTIAL_GT """ - Localized field key 'shipping_credential_id' for country ID. + Localized field key 'shipping_credential_id' for country Indonesia. """ SHIPPING_CREDENTIAL_ID """ - Localized field key 'shipping_credential_kr' for country KR. + Localized field key 'shipping_credential_kr' for country South Korea. """ SHIPPING_CREDENTIAL_KR """ - Localized field key 'shipping_credential_mx' for country MX. + Localized field key 'shipping_credential_mx' for country Mexico. """ SHIPPING_CREDENTIAL_MX """ - Localized field key 'shipping_credential_my' for country MY. + Localized field key 'shipping_credential_my' for country Malaysia. """ SHIPPING_CREDENTIAL_MY """ - Localized field key 'shipping_credential_pe' for country PE. + Localized field key 'shipping_credential_pe' for country Peru. """ SHIPPING_CREDENTIAL_PE """ - Localized field key 'shipping_credential_pt' for country PT. + Localized field key 'shipping_credential_pt' for country Portugal. """ SHIPPING_CREDENTIAL_PT """ - Localized field key 'shipping_credential_py' for country PY. + Localized field key 'shipping_credential_py' for country Paraguay. """ SHIPPING_CREDENTIAL_PY """ - Localized field key 'shipping_credential_tr' for country TR. + Localized field key 'shipping_credential_tr' for country Turkey. """ SHIPPING_CREDENTIAL_TR """ - Localized field key 'shipping_credential_tw' for country TW. + Localized field key 'shipping_credential_tw' for country Taiwan. """ SHIPPING_CREDENTIAL_TW """ - Localized field key 'shipping_credential_type_co' for country CO. + Localized field key 'shipping_credential_type_co' for country Colombia. """ SHIPPING_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_br' for country BR. + Localized field key 'tax_credential_br' for country Brazil. """ TAX_CREDENTIAL_BR """ - Localized field key 'tax_credential_cl' for country CL. + Localized field key 'tax_credential_cl' for country Chile. """ TAX_CREDENTIAL_CL """ - Localized field key 'tax_credential_co' for country CO. + Localized field key 'tax_credential_co' for country Colombia. """ TAX_CREDENTIAL_CO """ - Localized field key 'tax_credential_cr' for country CR. + Localized field key 'tax_credential_cr' for country Costa Rica. """ TAX_CREDENTIAL_CR """ - Localized field key 'tax_credential_ec' for country EC. + Localized field key 'tax_credential_ec' for country Ecuador. """ TAX_CREDENTIAL_EC """ - Localized field key 'tax_credential_es' for country ES. + Localized field key 'tax_credential_es' for country Spain. """ TAX_CREDENTIAL_ES """ - Localized field key 'tax_credential_gt' for country GT. + Localized field key 'tax_credential_gt' for country Guatemala. """ TAX_CREDENTIAL_GT """ - Localized field key 'tax_credential_id' for country ID. + Localized field key 'tax_credential_id' for country Indonesia. """ TAX_CREDENTIAL_ID """ - Localized field key 'tax_credential_it' for country IT. + Localized field key 'tax_credential_it' for country Italy. """ TAX_CREDENTIAL_IT """ - Localized field key 'tax_credential_mx' for country MX. + Localized field key 'tax_credential_mx' for country Mexico. """ TAX_CREDENTIAL_MX """ - Localized field key 'tax_credential_my' for country MY. + Localized field key 'tax_credential_my' for country Malaysia. """ TAX_CREDENTIAL_MY """ - Localized field key 'tax_credential_pe' for country PE. + Localized field key 'tax_credential_pe' for country Peru. """ TAX_CREDENTIAL_PE """ - Localized field key 'tax_credential_pt' for country PT. + Localized field key 'tax_credential_pt' for country Portugal. """ TAX_CREDENTIAL_PT """ - Localized field key 'tax_credential_py' for country PY. + Localized field key 'tax_credential_py' for country Paraguay. """ TAX_CREDENTIAL_PY """ - Localized field key 'tax_credential_tr' for country TR. + Localized field key 'tax_credential_tr' for country Turkey. """ TAX_CREDENTIAL_TR """ - Localized field key 'tax_credential_type_co' for country CO. + Localized field key 'tax_credential_type_co' for country Colombia. """ TAX_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_type_mx' for country MX. + Localized field key 'tax_credential_type_mx' for country Mexico. """ TAX_CREDENTIAL_TYPE_MX """ - Localized field key 'tax_credential_use_mx' for country MX. + Localized field key 'tax_credential_use_mx' for country Mexico. """ TAX_CREDENTIAL_USE_MX """ - Localized field key 'tax_email_it' for country IT. + Localized field key 'tax_email_it' for country Italy. """ TAX_EMAIL_IT } @@ -4065,7 +4249,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4108,16 +4292,24 @@ type Market implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4154,47 +4346,60 @@ type MarketRegionCountry implements MarketRegion { } """ -The merchandise to be purchased at checkout. +The item that a customer intends to purchase. Merchandise can be a product variant or a custom +product. + +A product variant is a specific version of a product that comes in more than one option, such as size or color. +For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be +one product variant and a large, blue t-shirt would be another. + +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ union Merchandise = CustomProduct | ProductVariant """ -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +[Custom fields](https://shopify.dev/docs/apps/build/custom-data) that store additional information +about a Shopify resource, such as products, orders, and +[many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). +Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) +enables you to customize the checkout experience. """ type Metafield { """ - The data stored in the metafield in JSON format. + The data that's stored in the metafield, using JSON format. """ jsonValue: JSON! """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + The [type of data](https://shopify.dev/apps/metafields/types) that the metafield stores in + the `value` field. """ type: String! """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + The data that's stored in the metafield. The data is always stored as a string, + regardless of the [metafield's type](https://shopify.dev/apps/metafields/types). """ value: String! } """ -A monetary value with currency. +A precise monetary value and its associated currency. For example, 12.99 USD. """ type MoneyV2 { """ - Decimal money amount. + A monetary value in decimal format, allowing for precise representation of cents or fractional + currency. For example, 12.99. """ amount: Decimal! """ - Currency of the money. + The three-letter currency code that represents a world currency used in a store. Currency codes + include standard [standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, + and non-standard codes. For example, USD. """ currencyCode: CurrencyCode! } @@ -4203,6 +4408,26 @@ type MoneyV2 { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.validations.generate.fetch target. + """ + cartValidationsGenerateFetch( + """ + The result of the Function. + """ + result: CartValidationsGenerateFetchResult! + ): Void! + + """ + Handles the Function result for the cart.validations.generate.run target. + """ + cartValidationsGenerateRun( + """ + The result of the Function. + """ + result: CartValidationsGenerateRunResult! + ): Void! + """ Handles the Function result for the purchase.validation.fetch target. """ @@ -4235,55 +4460,88 @@ type MutationRoot { } """ -Represents a product. +An operation to apply. +""" +input Operation @oneOf { + """ + Add a performed validation. + """ + validationAdd: ValidationAddOperation +} + +""" +The goods and services that merchants offer to customers. Products can include details such as +title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). +Products can be organized by grouping them into a collection. + +Learn more about [managing products in a merchant's store](https://help.shopify.com/manual/products). """ type Product implements HasMetafields { """ - A unique human-friendly string of the product's title. + A unique, human-readable string of the product's title. A handle can contain letters, hyphens (`-`), and + numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product + is titled "Black Sunglasses", then the handle is `black-sunglasses`. """ handle: Handle! """ - Whether the product has any of the given tags. + Whether the product is associated with any of the specified tags. The product must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with either the `sports` or `summer` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the product has the given tags. + Whether the product is associated with the specified tags. The product must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with both the `sports` and `summer` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product. """ id: ID! """ - Whether the product is in any of the given collections. + Whether the product is in any of the specified collections. The product must be in at least one collection + from the list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inAnyCollection( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): Boolean! """ - Whether the product is in the given collections. + Whether the product is in the specified collections. The product must be in all of the collections in the + list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inCollections( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): [CollectionMembership!]! @@ -4294,27 +4552,39 @@ type Product implements HasMetafields { isGiftCard: Boolean! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product type specified by the merchant. + A custom category for a product. Product types allow merchants to define categories other than the + ones available in Shopify's + [standard product categories](https://help.shopify.com/manual/products/details/product-type). """ productType: String """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! @@ -4325,62 +4595,81 @@ type Product implements HasMetafields { } """ -Represents a product variant. +A specific version of a product that comes in more than one option, such as size or color. For example, +if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one +product variant and a large, blue t-shirt would be another. """ type ProductVariant implements HasMetafields { """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product variant. """ id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product that this variant belongs to. + The product associated with the product variant. For example, if a + merchant sells t-shirts with options for size and color, then a small, + blue t-shirt would be one product variant and a large, blue t-shirt would be another. + The product associated with the product variant would be the t-shirt itself. """ product: Product! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + A case-sensitive identifier for the product variant in the merchant's store. For example, `"BBC-1"`. + A product variant must have a SKU to be connected to a + [fulfillment service](https://shopify.dev/docs/apps/build/orders-fulfillment/fulfillment-service-apps/build-for-fulfillment-services). """ sku: String """ - The localized title of the product variant in the customer’s locale. + The localized name for the product variant that displays to customers. """ title: String """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents information about the buyer that is interacting with the cart. +The company of a B2B customer that's interacting with the cart. +Used to manage and track purchases made by businesses rather than individual customers. """ type PurchasingCompany { """ @@ -4414,16 +4703,24 @@ type SellingPlan implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4483,25 +4780,35 @@ type SellingPlanAllocationPriceAdjustment { } """ -Information about the shop. +Information about the store, including the store's timezone setting +and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). """ type Shop implements HasMetafields { """ - Information about the current time relative to the shop's timezone setting. + The current time based on the + [store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ localTime: LocalTime! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4528,21 +4835,55 @@ A customization that validates a cart and/or checkout. """ type Validation implements HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } +""" +Add a performed validation. +""" +input ValidationAddOperation { + """ + Errors. + """ + errors: [ValidationError!]! +} + +""" +A Function error for a path. +""" +input ValidationError { + """ + Returns a message describing the error. + """ + message: String! + + """ + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. + """ + target: String! +} + """ A void type that can be used to return a null value from a mutation. """ diff --git a/checkout/javascript/cart-checkout-validation/default/shopify.extension.toml.liquid b/checkout/javascript/cart-checkout-validation/default/shopify.extension.toml.liquid index 38cff493..c0a06763 100644 --- a/checkout/javascript/cart-checkout-validation/default/shopify.extension.toml.liquid +++ b/checkout/javascript/cart-checkout-validation/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,11 +8,10 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.validation.run" + target = "cart.validations.generate.run" input_query = "src/run.graphql" export = "run" [extensions.build] command = "" path = "dist/function.wasm" - diff --git a/checkout/javascript/cart-checkout-validation/default/src/run.liquid b/checkout/javascript/cart-checkout-validation/default/src/run.liquid index 4c76a0a9..2466ce7c 100644 --- a/checkout/javascript/cart-checkout-validation/default/src/run.liquid +++ b/checkout/javascript/cart-checkout-validation/default/src/run.liquid @@ -3,42 +3,54 @@ /** * @typedef {import("../generated/api").RunInput} RunInput - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult + * @typedef {import("../generated/api").CartValidationsGenerateRunResult} CartValidationsGenerateRunResult */ /** * @param {RunInput} input - * @returns {FunctionRunResult} + * @returns {CartValidationsGenerateRunResult} */ export function run(input) { const errors = input.cart.lines .filter(({ quantity }) => quantity > 1) .map(() => ({ - localizedMessage: "Not possible to order more than one of each", - target: "$.cart", + message: "Not possible to order more than one of each", + target: "$.cart" })); - return { - errors - } + const operations = [ + { + validationAdd: { + errors + }, + }, + ]; + + return { operations }; }; {%- elsif flavor contains "typescript" -%} import type { RunInput, - FunctionRunResult, - FunctionError, + CartValidationsGenerateRunResult, + ValidationError, } from "../generated/api"; -export function run(input: RunInput): FunctionRunResult { - const errors: FunctionError[] = input.cart.lines +export function run(input: RunInput): CartValidationsGenerateRunResult { + const errors: ValidationError[] = input.cart.lines .filter(({ quantity }) => quantity > 1) .map(() => ({ - localizedMessage: "Not possible to order more than one of each", - target: "$.cart", + message: "Not possible to order more than one of each", + target: "$.cart" })); - return { - errors - } + const operations = [ + { + validationAdd: { + errors + }, + }, + ]; + + return { operations }; }; {%- endif -%} diff --git a/checkout/javascript/cart-checkout-validation/default/src/run.test.liquid b/checkout/javascript/cart-checkout-validation/default/src/run.test.liquid index 47eefa63..101b7281 100644 --- a/checkout/javascript/cart-checkout-validation/default/src/run.test.liquid +++ b/checkout/javascript/cart-checkout-validation/default/src/run.test.liquid @@ -3,7 +3,7 @@ import { describe, it, expect } from 'vitest'; import { run } from './run'; /** - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult + * @typedef {import("../generated/api").CartValidationsGenerateRunResult} CartValidationsGenerateRunResult */ describe('cart checkout validation function', () => { @@ -17,12 +17,20 @@ describe('cart checkout validation function', () => { ] } }); - const expected = /** @type {FunctionRunResult} */ ({ errors: [ - { - localizedMessage: "Not possible to order more than one of each", - target: "$.cart" - } - ] }); + const expected = /** @type {CartValidationsGenerateRunResult} */ ({ + operations: [ + { + validationAdd: { + errors: [ + { + message: "Not possible to order more than one of each", + target: "$.cart" + } + ] + } + } + ] + }); expect(result).toEqual(expected); }); @@ -37,15 +45,24 @@ describe('cart checkout validation function', () => { ] } }); - const expected = /** @type {FunctionRunResult} */ ({ errors: [] }); + const expected = /** @type {CartValidationsGenerateRunResult} */ ({ + operations: [ + { + validationAdd: { + errors: [] + } + } + ] + }); expect(result).toEqual(expected); }); }); + {%- elsif flavor contains "typescript" -%} import { describe, it, expect } from 'vitest'; import { run } from './run'; -import { FunctionRunResult } from "../generated/api"; +import { CartValidationsGenerateRunResult } from "../generated/api"; describe('cart checkout validation function', () => { it('returns an error when quantity exceeds one', () => { @@ -58,12 +75,20 @@ describe('cart checkout validation function', () => { ] } }); - const expected: FunctionRunResult = { errors: [ - { - localizedMessage: "Not possible to order more than one of each", - target: "$.cart" - } - ] }; + const expected: CartValidationsGenerateRunResult = { + operations: [ + { + validationAdd: { + errors: [ + { + message: "Not possible to order more than one of each", + target: "$.cart" + } + ] + } + } + ] + }; expect(result).toEqual(expected); }); @@ -78,7 +103,15 @@ describe('cart checkout validation function', () => { ] } }); - const expected: FunctionRunResult = { errors: [] }; + const expected: CartValidationsGenerateRunResult = { + operations: [ + { + validationAdd: { + errors: [] + } + } + ] + }; expect(result).toEqual(expected); }); diff --git a/checkout/rust/cart-checkout-validation/default/schema.graphql b/checkout/rust/cart-checkout-validation/default/schema.graphql index 705a319e..27148a73 100644 --- a/checkout/rust/cart-checkout-validation/default/schema.graphql +++ b/checkout/rust/cart-checkout-validation/default/schema.graphql @@ -14,11 +14,22 @@ Scale the Functions resource limits based on the field's length. directive @scaleLimits(rate: Float!) on FIELD_DEFINITION """ -Represents a generic custom attribute, such as whether an order is a customer's first. +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +A custom property. Attributes are used to store additional information about a Shopify resource, such as +products, customers, or orders. Attributes are stored as key-value pairs. + +For example, a list of attributes might include whether a customer is a first-time buyer (`"customer_first_order": "true"`), +whether an order is gift-wrapped (`"gift_wrapped": "true"`), a preferred delivery date +(`"preferred_delivery_date": "2025-10-01"`), the discount applied (`"loyalty_discount_applied": "10%"`), and any +notes provided by the customer (`"customer_notes": "Please leave at the front door"`). """ type Attribute { """ - The key or name of the attribute. For example, `"customersFirstOrder"`. + The key or name of the attribute. For example, `"customer_first_order"`. """ key: String! @@ -29,31 +40,39 @@ type Attribute { } """ -Represents information about the buyer that is interacting with the cart. +Information about the customer that's interacting with the cart. It includes details such as the +customer's email and phone number, and the total amount of money the customer has spent in the store. +This information helps personalize the checkout experience and ensures that accurate pricing and delivery options +are displayed to customers. """ type BuyerIdentity { """ - The customer associated with the cart. + The customer that's interacting with the cart. A customer is a buyer who has an + [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. """ customer: Customer """ - The email address of the buyer that's interacting with the cart. + The email address of the customer that's interacting with the cart. """ email: String """ - Whether the buyer authenticated with a customer account. + Whether the customer is authenticated through their + [customer account](https://help.shopify.com/manual/customers/customer-accounts). + If the customer is authenticated, then the `customer` field returns the customer's information. + If the customer isn't authenticated, then the `customer` field returns `null`. """ isAuthenticated: Boolean! """ - The phone number of the buyer that's interacting with the cart. + The phone number of the customer that's interacting with the cart. """ phone: String """ - The purchasing company associated with the cart. + The company of a B2B customer that's interacting with the cart. + Used to manage and track purchases made by businesses rather than individual customers. """ purchasingCompany: PurchasingCompany } @@ -83,46 +102,59 @@ enum BuyerJourneyStep { } """ -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase +and information about the customer, such as the customer's email address and phone number. """ type Cart { """ - The attributes associated with the cart. Attributes are represented as key-value pairs. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - Information about the buyer that is interacting with the cart. + Information about the customer that's interacting with the cart. It includes details such as the + customer's email and phone number, and the total amount of money the customer has spent in the store. + This information helps personalize the checkout experience and ensures that accurate pricing and delivery options + are displayed to customers. """ buyerIdentity: BuyerIdentity """ - The costs that the buyer will pay at checkout. + A breakdown of the costs that the customer will pay at checkout. It includes the total amount, + the subtotal before taxes and duties, the tax amount, and duty charges. """ cost: CartCost! """ - A list of lines containing information about the items that can be delivered. + The items in a cart that are eligible for fulfillment and can be delivered to the customer. """ deliverableLines: [DeliverableCartLine!]! """ - The delivery groups available for the cart based on the buyer's shipping address. + A collection of items that are grouped by shared delivery characteristics. Delivery groups streamline + fulfillment by organizing items that can be shipped together, based on the customer's + shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped + together, then the items are included in the same delivery group. """ deliveryGroups: [CartDeliveryGroup!]! """ - A list of lines containing information about the items the customer intends to purchase. + The items in a cart that the customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ lines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The localized fields available for the cart. + The additional fields on the **Cart** page that are required for international orders in specific countries, + such as customs information or tax identification numbers. """ localizedFields( """ @@ -133,113 +165,140 @@ type Cart { } """ -The cost that the buyer will pay at checkout. +A breakdown of the costs that the customer will pay at checkout. It includes the total amount, +the subtotal before taxes and duties, the tax amount, and duty charges. """ type CartCost { """ - The amount, before taxes and discounts, for the customer to pay. + The amount for the customer to pay at checkout, excluding taxes and discounts. """ subtotalAmount: MoneyV2! """ - The total amount for the customer to pay. + The total amount for the customer to pay at checkout. """ totalAmount: MoneyV2! """ - The duty amount for the customer to pay at checkout. + The duty charges for a customer to pay at checkout. """ totalDutyAmount: MoneyV2 """ - The tax amount for the customer to pay at checkout. + The total tax amount for the customer to pay at checkout. """ totalTaxAmount: MoneyV2 } """ -Information about the options available for one or more line items to be delivered to a specific address. +Information about items in a cart that are grouped by shared delivery characteristics. +Delivery groups streamline fulfillment by organizing items that can be shipped together, based on the customer's +shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped +together, then the items are included in the same delivery group. """ type CartDeliveryGroup { """ - A list of cart lines for the delivery group. + Information about items in a cart that a customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ cartLines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The destination address for the delivery group. + The shipping or destination address associated with the delivery group. """ deliveryAddress: MailingAddress """ - The delivery options available for the delivery group. + The delivery options available for the delivery group. Delivery options are the different ways that customers + can choose to have their orders shipped. Examples include express shipping or standard shipping. """ deliveryOptions: [CartDeliveryOption!]! """ - Unique identifier for the delivery group. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the delivery group. """ id: ID! """ - Information about the delivery option the buyer has selected. + Information about the delivery option that the customer has selected. """ selectedDeliveryOption: CartDeliveryOption } """ -Information about a delivery option. +Information about a delivery option that's available for an item in a cart. Delivery options are the different +ways that customers can choose to have their orders shipped. Examples include express shipping or standard +shipping. """ type CartDeliveryOption { """ - The code of the delivery option. + A unique identifier that represents the delivery option offered to customers. + For example, `Canada Post Expedited`. """ code: String """ - The cost for the delivery option. + The amount that the customer pays if they select the delivery option. """ cost: MoneyV2! """ - The method for the delivery option. + The delivery method associated with the delivery option. A delivery method is a way that merchants can + fulfill orders from their online stores. Delivery methods include shipping to an address, + [local pickup](https://help.shopify.com/manual/fulfillment/setup/delivery-methods/pickup-in-store), + and shipping to a [pickup point](https://help.shopify.com/manual/fulfillment/shopify-shipping/pickup-points), + all of which are natively supported by Shopify checkout. """ deliveryMethodType: DeliveryMethod! """ - The description of the delivery option. + A single-line description of the delivery option, with HTML tags removed. """ description: String """ - The unique identifier of the delivery option. + A unique, human-readable identifier of the delivery option's title. + A handle can contain letters, hyphens (`-`), and numbers, but not spaces. + For example, `standard-shipping`. """ handle: Handle! """ - The title of the delivery option. + The name of the delivery option that displays to customers. The title is used to construct the delivery + option's handle. For example, if a delivery option is titled "Standard Shipping", then the handle is + `standard-shipping`. """ title: String } """ -Represents information about the merchandise in the cart. +Information about an item in a cart that a customer intends to purchase. A cart line is an entry in the +customer's cart that represents a single unit of a product variant. For example, if a customer adds two +different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - The cost of the merchandise line that the buyer will pay at checkout. + The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's + cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of + the same t-shirt to their cart, then each size is represented as a separate cart line. """ cost: CartLineCost! @@ -249,59 +308,92 @@ type CartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. + The [selling plan](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + associated with the cart line, including information about how a product variant can be sold and purchased. """ sellingPlanAllocation: SellingPlanAllocation } """ -The cost of the merchandise line that the buyer will pay at checkout. +The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's +cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of +the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLineCost { """ - The amount of the merchandise line. + The cost of a single unit. For example, if a customer purchases three units of a product + that are priced at $10 each, then the `amountPerQuantity` is $10. """ amountPerQuantity: MoneyV2! """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. + The cost of a single unit before any discounts are applied. This field is used to calculate and display + savings for customers. For example, if a product's `compareAtAmountPerQuantity` is $25 and its current price + is $20, then the customer sees a $5 discount. This value can change based on the buyer's identity and is + `null` when the value is hidden from buyers. """ compareAtAmountPerQuantity: MoneyV2 """ - The cost of the merchandise line before line-level discounts. + The cost of items in the cart before applying any discounts to certain items. + This amount serves as the starting point for calculating any potential savings customers + might receive through promotions or discounts. """ subtotalAmount: MoneyV2! """ - The total cost of the merchandise line. + The total cost of items in a cart. """ totalAmount: MoneyV2! } """ -Represents whether the product is a member of the given collection. +The fetch target result. Your Function must return this data structure when generating the request. +""" +input CartValidationsGenerateFetchResult { + """ + The attributes associated with an HTTP request. + """ + request: HttpRequest +} + +""" +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. +""" +input CartValidationsGenerateRunResult { + """ + The ordered list of operations to apply. + """ + operations: [Operation!]! +} + +""" +Whether the product is in the specified collection. + +A collection is a group of products that can be displayed in online stores and other sales channels in +categories, which makes it easy for customers to find them. For example, an athletics store might create +different collections for running attire and accessories. """ type CollectionMembership { """ - The ID of the collection. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the collection. """ collectionId: ID! """ - Whether the product is a member of the collection. + Whether the product is in the specified collection. """ isMember: Boolean! } @@ -326,16 +418,24 @@ type Company implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -409,16 +509,24 @@ type CompanyLocation implements HasMetafields { locale: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -436,7 +544,9 @@ type CompanyLocation implements HasMetafields { } """ -A country. +The country for which the store is customized, reflecting local preferences and regulations. +Localization might influence the language, currency, and product offerings available in a store to enhance +the shopping experience for customers in that region. """ type Country { """ @@ -1679,9 +1789,8 @@ enum CountryCode { } """ -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. +The three-letter currency codes that represent the world currencies used in stores. Currency codes include +[standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, and non-standard codes. """ enum CurrencyCode { """ @@ -2491,7 +2600,10 @@ enum CurrencyCode { } """ -A custom product. +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ type CustomProduct { """ @@ -2500,43 +2612,51 @@ type CustomProduct { isGiftCard: Boolean! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents a customer with the shop. +Represents a [customer](https://help.shopify.com/manual/customers/manage-customers) +who has an [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. +`Customer` returns data including the customer's contact information and order history. """ type Customer implements HasMetafields { """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. + The total amount that the customer has spent on orders. + The amount is converted from the shop's currency to the currency of the cart using a market rate. """ amountSpent: MoneyV2! """ - The customer’s name, email or phone number. + The full name of the customer, based on the values for `firstName` and `lastName`. + If `firstName` and `lastName` aren't specified, then the value is the customer's email address. + If the email address isn't specified, then the value is the customer's phone number. """ displayName: String! """ - The customer’s email address. + The customer's email address. """ email: String @@ -2546,27 +2666,32 @@ type Customer implements HasMetafields { firstName: String """ - Whether the customer has any of the given tags. + Whether the customer is associated with any of the specified tags. The customer must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to search for. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with either the `VIP` or `Gold` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the customer has the given tags. + Whether the customer is associated with the specified tags. The customer must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with both the `VIP` and `Gold` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A unique identifier for the customer. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the customer. """ id: ID! @@ -2576,22 +2701,30 @@ type Customer implements HasMetafields { lastName: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The number of orders made by the customer. + The total number of orders that the customer has made at the store. """ numberOfOrders: Int! } @@ -2629,13 +2762,17 @@ Represents information about the merchandise in the cart. """ type DeliverableCartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute @@ -2646,12 +2783,12 @@ type DeliverableCartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! } @@ -2701,37 +2838,42 @@ input FunctionError { localizedMessage: String! """ - Specifies the path/target for use by the UI. + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. """ target: String! } """ -The fetch target result. Refer to network access for Shopify Functions. +The fetch target result. Your Function must return this data structure when generating the request. """ input FunctionFetchResult { """ - HTTP Request. + The attributes associated with an HTTP request. """ request: HttpRequest } """ -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. In +API versions 2023-10 and beyond, this type is deprecated in favor of +`FunctionRunResult`. """ input FunctionResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } """ -The run target result. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. """ input FunctionRunResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } @@ -2748,32 +2890,42 @@ Represents information about the metafields associated to the specified resource """ interface HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } """ -Represents whether the current object has the given tag. +Whether a Shopify resource, such as a product or customer, has a specified tag. """ type HasTagResponse { """ - Whether the current object has the tag. + Whether the Shopify resource has the tag. """ hasTag: Boolean! """ - The tag. + A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, + a merchant might apply the `sports` and `summer` tags to products that are associated with sportswear for + summer. """ tag: String! } @@ -2886,9 +3038,9 @@ type HttpResponse { headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. + The HTTP response body parsed as JSON. + If the body is valid JSON, it will be parsed and returned as a JSON object. + If parsing fails, then raw body is returned as a string. Use this field when you expect the response to be JSON, or when you're dealing with mixed response types, meaning both JSON and non-JSON. Using this field reduces function instruction consumption and ensures that the data is formatted in logs. @@ -2926,39 +3078,63 @@ Example value: `"gid://shopify/Product/10079785100"` """ scalar ID +""" +The `Input` object is the complete GraphQL schema that your Function can receive +as input to validate cart and checkout. Your Function receives only the fields +that you request in the input query. To optimize performance, we highly +recommend that you request only the fields that your Function requires. +""" type Input { """ - The buyer journey step. + Information about the current step in the buyer's purchasing process. The + buyer journey helps you determine where the customer is in their shopping + experience (for example, cart interaction, checkout interaction, or completing + a checkout). You can use this information to apply appropriate validation + rules based on the customer's current context and create a more tailored and + performant shopping experience. """ buyerJourney: BuyerJourney! """ - The cart. + The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase + and information about the customer, such as the customer's email address and phone number. """ cart: Cart! """ - The result of the fetch target. Refer to network access for Shopify Functions. + The `FunctionFetchResult` object is the result of the fetch target. This is + the response that Shopify returns after executing the HTTP request defined in + your fetch target, and that is passed as input to the run target. For more + information, refer to [network access for Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/network-access). """ - fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run"]) + fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run", "cart.validations.generate.run"]) """ - The localization of the Function execution context. + The regional and language settings that determine how the Function + handles currency, numbers, dates, and other locale-specific values + during discount calculations. These settings are based on the store's configured + [localization practices](https://shopify.dev/docs/apps/build/functions/localization-practices-shopify-functions). """ localization: Localization! """ - The conversion rate between the shop's currency and the currency of the cart. + The exchange rate used to convert discounts between the shop's default + currency and the currency that displays to the customer during checkout. + For example, if a store operates in USD but a customer is viewing discounts in EUR, + then the presentment currency rate handles this conversion for accurate pricing. """ presentmentCurrencyRate: Decimal! """ - Information about the shop. + Information about the shop where the Function is running, including the shop's timezone + setting and associated [metafields](https://shopify.dev/docs/apps/build/custom-data). """ shop: Shop! """ - The validation rule that owns the current function. + The configuration of the app that owns the Function. This configuration + controls how merchants can define validation rules for carts and checkout, + such as inventory checks, price validations, or custom purchase restrictions. """ validation: Validation! } @@ -2981,7 +3157,8 @@ Example value: scalar JSON """ -A language. +The language for which the store is customized, ensuring content is tailored to local customers. +This includes product descriptions and customer communications that resonate with the target audience. """ type Language { """ @@ -3701,7 +3878,8 @@ enum LanguageCode { } """ -Represents limited information about the current time relative to the parent object. +The current time based on the +[store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ type LocalTime { """ @@ -3781,23 +3959,29 @@ type LocalTime { } """ -Information about the localized experiences configured for the shop. +Details about the localized experience for the store in a specific region, including country and language +settings. The localized experience is determined by the store's settings and the customer's location. +Localization ensures that customers can access relevant content and options while browsing or purchasing +products in a store. """ type Localization { """ - The country of the active localized experience. + The country for which the store is customized, reflecting local preferences and regulations. + Localization might influence the language, currency, and product offerings available in a store to enhance + the shopping experience for customers in that region. """ country: Country! """ - The language of the active localized experience. + The language for which the store is customized, ensuring content is tailored to local customers. + This includes product descriptions and customer communications that resonate with the target audience. """ language: Language! """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -3828,187 +4012,187 @@ Unique key identifying localized fields. """ enum LocalizedFieldKey { """ - Localized field key 'shipping_credential_br' for country BR. + Localized field key 'shipping_credential_br' for country Brazil. """ SHIPPING_CREDENTIAL_BR """ - Localized field key 'shipping_credential_cl' for country CL. + Localized field key 'shipping_credential_cl' for country Chile. """ SHIPPING_CREDENTIAL_CL """ - Localized field key 'shipping_credential_cn' for country CN. + Localized field key 'shipping_credential_cn' for country China. """ SHIPPING_CREDENTIAL_CN """ - Localized field key 'shipping_credential_co' for country CO. + Localized field key 'shipping_credential_co' for country Colombia. """ SHIPPING_CREDENTIAL_CO """ - Localized field key 'shipping_credential_cr' for country CR. + Localized field key 'shipping_credential_cr' for country Costa Rica. """ SHIPPING_CREDENTIAL_CR """ - Localized field key 'shipping_credential_ec' for country EC. + Localized field key 'shipping_credential_ec' for country Ecuador. """ SHIPPING_CREDENTIAL_EC """ - Localized field key 'shipping_credential_es' for country ES. + Localized field key 'shipping_credential_es' for country Spain. """ SHIPPING_CREDENTIAL_ES """ - Localized field key 'shipping_credential_gt' for country GT. + Localized field key 'shipping_credential_gt' for country Guatemala. """ SHIPPING_CREDENTIAL_GT """ - Localized field key 'shipping_credential_id' for country ID. + Localized field key 'shipping_credential_id' for country Indonesia. """ SHIPPING_CREDENTIAL_ID """ - Localized field key 'shipping_credential_kr' for country KR. + Localized field key 'shipping_credential_kr' for country South Korea. """ SHIPPING_CREDENTIAL_KR """ - Localized field key 'shipping_credential_mx' for country MX. + Localized field key 'shipping_credential_mx' for country Mexico. """ SHIPPING_CREDENTIAL_MX """ - Localized field key 'shipping_credential_my' for country MY. + Localized field key 'shipping_credential_my' for country Malaysia. """ SHIPPING_CREDENTIAL_MY """ - Localized field key 'shipping_credential_pe' for country PE. + Localized field key 'shipping_credential_pe' for country Peru. """ SHIPPING_CREDENTIAL_PE """ - Localized field key 'shipping_credential_pt' for country PT. + Localized field key 'shipping_credential_pt' for country Portugal. """ SHIPPING_CREDENTIAL_PT """ - Localized field key 'shipping_credential_py' for country PY. + Localized field key 'shipping_credential_py' for country Paraguay. """ SHIPPING_CREDENTIAL_PY """ - Localized field key 'shipping_credential_tr' for country TR. + Localized field key 'shipping_credential_tr' for country Turkey. """ SHIPPING_CREDENTIAL_TR """ - Localized field key 'shipping_credential_tw' for country TW. + Localized field key 'shipping_credential_tw' for country Taiwan. """ SHIPPING_CREDENTIAL_TW """ - Localized field key 'shipping_credential_type_co' for country CO. + Localized field key 'shipping_credential_type_co' for country Colombia. """ SHIPPING_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_br' for country BR. + Localized field key 'tax_credential_br' for country Brazil. """ TAX_CREDENTIAL_BR """ - Localized field key 'tax_credential_cl' for country CL. + Localized field key 'tax_credential_cl' for country Chile. """ TAX_CREDENTIAL_CL """ - Localized field key 'tax_credential_co' for country CO. + Localized field key 'tax_credential_co' for country Colombia. """ TAX_CREDENTIAL_CO """ - Localized field key 'tax_credential_cr' for country CR. + Localized field key 'tax_credential_cr' for country Costa Rica. """ TAX_CREDENTIAL_CR """ - Localized field key 'tax_credential_ec' for country EC. + Localized field key 'tax_credential_ec' for country Ecuador. """ TAX_CREDENTIAL_EC """ - Localized field key 'tax_credential_es' for country ES. + Localized field key 'tax_credential_es' for country Spain. """ TAX_CREDENTIAL_ES """ - Localized field key 'tax_credential_gt' for country GT. + Localized field key 'tax_credential_gt' for country Guatemala. """ TAX_CREDENTIAL_GT """ - Localized field key 'tax_credential_id' for country ID. + Localized field key 'tax_credential_id' for country Indonesia. """ TAX_CREDENTIAL_ID """ - Localized field key 'tax_credential_it' for country IT. + Localized field key 'tax_credential_it' for country Italy. """ TAX_CREDENTIAL_IT """ - Localized field key 'tax_credential_mx' for country MX. + Localized field key 'tax_credential_mx' for country Mexico. """ TAX_CREDENTIAL_MX """ - Localized field key 'tax_credential_my' for country MY. + Localized field key 'tax_credential_my' for country Malaysia. """ TAX_CREDENTIAL_MY """ - Localized field key 'tax_credential_pe' for country PE. + Localized field key 'tax_credential_pe' for country Peru. """ TAX_CREDENTIAL_PE """ - Localized field key 'tax_credential_pt' for country PT. + Localized field key 'tax_credential_pt' for country Portugal. """ TAX_CREDENTIAL_PT """ - Localized field key 'tax_credential_py' for country PY. + Localized field key 'tax_credential_py' for country Paraguay. """ TAX_CREDENTIAL_PY """ - Localized field key 'tax_credential_tr' for country TR. + Localized field key 'tax_credential_tr' for country Turkey. """ TAX_CREDENTIAL_TR """ - Localized field key 'tax_credential_type_co' for country CO. + Localized field key 'tax_credential_type_co' for country Colombia. """ TAX_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_type_mx' for country MX. + Localized field key 'tax_credential_type_mx' for country Mexico. """ TAX_CREDENTIAL_TYPE_MX """ - Localized field key 'tax_credential_use_mx' for country MX. + Localized field key 'tax_credential_use_mx' for country Mexico. """ TAX_CREDENTIAL_USE_MX """ - Localized field key 'tax_email_it' for country IT. + Localized field key 'tax_email_it' for country Italy. """ TAX_EMAIL_IT } @@ -4065,7 +4249,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4108,16 +4292,24 @@ type Market implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4154,47 +4346,60 @@ type MarketRegionCountry implements MarketRegion { } """ -The merchandise to be purchased at checkout. +The item that a customer intends to purchase. Merchandise can be a product variant or a custom +product. + +A product variant is a specific version of a product that comes in more than one option, such as size or color. +For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be +one product variant and a large, blue t-shirt would be another. + +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ union Merchandise = CustomProduct | ProductVariant """ -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +[Custom fields](https://shopify.dev/docs/apps/build/custom-data) that store additional information +about a Shopify resource, such as products, orders, and +[many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). +Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) +enables you to customize the checkout experience. """ type Metafield { """ - The data stored in the metafield in JSON format. + The data that's stored in the metafield, using JSON format. """ jsonValue: JSON! """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + The [type of data](https://shopify.dev/apps/metafields/types) that the metafield stores in + the `value` field. """ type: String! """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + The data that's stored in the metafield. The data is always stored as a string, + regardless of the [metafield's type](https://shopify.dev/apps/metafields/types). """ value: String! } """ -A monetary value with currency. +A precise monetary value and its associated currency. For example, 12.99 USD. """ type MoneyV2 { """ - Decimal money amount. + A monetary value in decimal format, allowing for precise representation of cents or fractional + currency. For example, 12.99. """ amount: Decimal! """ - Currency of the money. + The three-letter currency code that represents a world currency used in a store. Currency codes + include standard [standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, + and non-standard codes. For example, USD. """ currencyCode: CurrencyCode! } @@ -4203,6 +4408,26 @@ type MoneyV2 { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.validations.generate.fetch target. + """ + cartValidationsGenerateFetch( + """ + The result of the Function. + """ + result: CartValidationsGenerateFetchResult! + ): Void! + + """ + Handles the Function result for the cart.validations.generate.run target. + """ + cartValidationsGenerateRun( + """ + The result of the Function. + """ + result: CartValidationsGenerateRunResult! + ): Void! + """ Handles the Function result for the purchase.validation.fetch target. """ @@ -4235,55 +4460,88 @@ type MutationRoot { } """ -Represents a product. +An operation to apply. +""" +input Operation @oneOf { + """ + Add a performed validation. + """ + validationAdd: ValidationAddOperation +} + +""" +The goods and services that merchants offer to customers. Products can include details such as +title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). +Products can be organized by grouping them into a collection. + +Learn more about [managing products in a merchant's store](https://help.shopify.com/manual/products). """ type Product implements HasMetafields { """ - A unique human-friendly string of the product's title. + A unique, human-readable string of the product's title. A handle can contain letters, hyphens (`-`), and + numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product + is titled "Black Sunglasses", then the handle is `black-sunglasses`. """ handle: Handle! """ - Whether the product has any of the given tags. + Whether the product is associated with any of the specified tags. The product must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with either the `sports` or `summer` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the product has the given tags. + Whether the product is associated with the specified tags. The product must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with both the `sports` and `summer` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product. """ id: ID! """ - Whether the product is in any of the given collections. + Whether the product is in any of the specified collections. The product must be in at least one collection + from the list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inAnyCollection( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): Boolean! """ - Whether the product is in the given collections. + Whether the product is in the specified collections. The product must be in all of the collections in the + list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inCollections( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): [CollectionMembership!]! @@ -4294,27 +4552,39 @@ type Product implements HasMetafields { isGiftCard: Boolean! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product type specified by the merchant. + A custom category for a product. Product types allow merchants to define categories other than the + ones available in Shopify's + [standard product categories](https://help.shopify.com/manual/products/details/product-type). """ productType: String """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! @@ -4325,62 +4595,81 @@ type Product implements HasMetafields { } """ -Represents a product variant. +A specific version of a product that comes in more than one option, such as size or color. For example, +if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one +product variant and a large, blue t-shirt would be another. """ type ProductVariant implements HasMetafields { """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product variant. """ id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product that this variant belongs to. + The product associated with the product variant. For example, if a + merchant sells t-shirts with options for size and color, then a small, + blue t-shirt would be one product variant and a large, blue t-shirt would be another. + The product associated with the product variant would be the t-shirt itself. """ product: Product! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + A case-sensitive identifier for the product variant in the merchant's store. For example, `"BBC-1"`. + A product variant must have a SKU to be connected to a + [fulfillment service](https://shopify.dev/docs/apps/build/orders-fulfillment/fulfillment-service-apps/build-for-fulfillment-services). """ sku: String """ - The localized title of the product variant in the customer’s locale. + The localized name for the product variant that displays to customers. """ title: String """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents information about the buyer that is interacting with the cart. +The company of a B2B customer that's interacting with the cart. +Used to manage and track purchases made by businesses rather than individual customers. """ type PurchasingCompany { """ @@ -4414,16 +4703,24 @@ type SellingPlan implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4483,25 +4780,35 @@ type SellingPlanAllocationPriceAdjustment { } """ -Information about the shop. +Information about the store, including the store's timezone setting +and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). """ type Shop implements HasMetafields { """ - Information about the current time relative to the shop's timezone setting. + The current time based on the + [store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ localTime: LocalTime! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4528,21 +4835,55 @@ A customization that validates a cart and/or checkout. """ type Validation implements HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } +""" +Add a performed validation. +""" +input ValidationAddOperation { + """ + Errors. + """ + errors: [ValidationError!]! +} + +""" +A Function error for a path. +""" +input ValidationError { + """ + Returns a message describing the error. + """ + message: String! + + """ + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. + """ + target: String! +} + """ A void type that can be used to return a null value from a mutation. """ diff --git a/checkout/rust/cart-checkout-validation/default/shopify.extension.toml.liquid b/checkout/rust/cart-checkout-validation/default/shopify.extension.toml.liquid index 1851f0e5..3efb7d4c 100644 --- a/checkout/rust/cart-checkout-validation/default/shopify.extension.toml.liquid +++ b/checkout/rust/cart-checkout-validation/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,7 +8,7 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.validation.run" + target = "cart.validations.generate.run" input_query = "src/run.graphql" export = "run" @@ -16,4 +16,3 @@ description = "t:description" command = "cargo build --target=wasm32-wasip1 --release" path = "target/wasm32-wasip1/release/{{handle | replace: " ", "-" | downcase}}.wasm" watch = ["src/**/*.rs"] - diff --git a/checkout/rust/cart-checkout-validation/default/src/run.rs b/checkout/rust/cart-checkout-validation/default/src/run.rs index ca0fef5d..1953c33d 100644 --- a/checkout/rust/cart-checkout-validation/default/src/run.rs +++ b/checkout/rust/cart-checkout-validation/default/src/run.rs @@ -7,7 +7,8 @@ use serde::{Deserialize, Serialize}; struct Config {} #[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] -fn run(input: input::ResponseData) -> Result { +fn run(input: input::ResponseData) -> Result { + let mut operations = Vec::new(); let mut errors = Vec::new(); if input @@ -17,12 +18,16 @@ fn run(input: input::ResponseData) -> Result { .map(|line| line.quantity) .any(|quantity| quantity > 1) { - errors.push(output::FunctionError { - localized_message: "Not possible to order more than one of each".to_owned(), + errors.push(output::ValidationError { + message: "Not possible to order more than one of each".to_owned(), target: "$.cart".to_owned(), }) } - Ok(output::FunctionRunResult { errors }) + + let operation = output::ValidationAddOperation { errors }; + operations.push(output::Operation::ValidationAdd(operation)); + + Ok(output::CartValidationsGenerateRunResult { operations }) } #[cfg(test)] @@ -48,11 +53,13 @@ mod tests { } "#, )?; - let expected = FunctionRunResult { - errors: vec![FunctionError { - localized_message: "Not possible to order more than one of each".to_owned(), - target: "$.cart".to_owned(), - }], + let expected = CartValidationsGenerateRunResult { + operations: vec![Operation::ValidationAdd(ValidationAddOperation { + errors: vec![ValidationError { + message: "Not possible to order more than one of each".to_owned(), + target: "$.cart".to_owned(), + }], + })], }; assert_eq!(result, expected); @@ -77,7 +84,11 @@ mod tests { } "#, )?; - let expected = FunctionRunResult { errors: vec![] }; + let expected = CartValidationsGenerateRunResult { + operations: vec![Operation::ValidationAdd(ValidationAddOperation { + errors: vec![], + })], + }; assert_eq!(result, expected); Ok(()) diff --git a/checkout/wasm/cart-checkout-validation/default/schema.graphql b/checkout/wasm/cart-checkout-validation/default/schema.graphql index 705a319e..27148a73 100644 --- a/checkout/wasm/cart-checkout-validation/default/schema.graphql +++ b/checkout/wasm/cart-checkout-validation/default/schema.graphql @@ -14,11 +14,22 @@ Scale the Functions resource limits based on the field's length. directive @scaleLimits(rate: Float!) on FIELD_DEFINITION """ -Represents a generic custom attribute, such as whether an order is a customer's first. +Requires that exactly one field must be supplied and that field must not be `null`. +""" +directive @oneOf on INPUT_OBJECT + +""" +A custom property. Attributes are used to store additional information about a Shopify resource, such as +products, customers, or orders. Attributes are stored as key-value pairs. + +For example, a list of attributes might include whether a customer is a first-time buyer (`"customer_first_order": "true"`), +whether an order is gift-wrapped (`"gift_wrapped": "true"`), a preferred delivery date +(`"preferred_delivery_date": "2025-10-01"`), the discount applied (`"loyalty_discount_applied": "10%"`), and any +notes provided by the customer (`"customer_notes": "Please leave at the front door"`). """ type Attribute { """ - The key or name of the attribute. For example, `"customersFirstOrder"`. + The key or name of the attribute. For example, `"customer_first_order"`. """ key: String! @@ -29,31 +40,39 @@ type Attribute { } """ -Represents information about the buyer that is interacting with the cart. +Information about the customer that's interacting with the cart. It includes details such as the +customer's email and phone number, and the total amount of money the customer has spent in the store. +This information helps personalize the checkout experience and ensures that accurate pricing and delivery options +are displayed to customers. """ type BuyerIdentity { """ - The customer associated with the cart. + The customer that's interacting with the cart. A customer is a buyer who has an + [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. """ customer: Customer """ - The email address of the buyer that's interacting with the cart. + The email address of the customer that's interacting with the cart. """ email: String """ - Whether the buyer authenticated with a customer account. + Whether the customer is authenticated through their + [customer account](https://help.shopify.com/manual/customers/customer-accounts). + If the customer is authenticated, then the `customer` field returns the customer's information. + If the customer isn't authenticated, then the `customer` field returns `null`. """ isAuthenticated: Boolean! """ - The phone number of the buyer that's interacting with the cart. + The phone number of the customer that's interacting with the cart. """ phone: String """ - The purchasing company associated with the cart. + The company of a B2B customer that's interacting with the cart. + Used to manage and track purchases made by businesses rather than individual customers. """ purchasingCompany: PurchasingCompany } @@ -83,46 +102,59 @@ enum BuyerJourneyStep { } """ -A cart represents the merchandise that a buyer intends to purchase, and the cost associated with the cart. +The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase +and information about the customer, such as the customer's email address and phone number. """ type Cart { """ - The attributes associated with the cart. Attributes are represented as key-value pairs. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - Information about the buyer that is interacting with the cart. + Information about the customer that's interacting with the cart. It includes details such as the + customer's email and phone number, and the total amount of money the customer has spent in the store. + This information helps personalize the checkout experience and ensures that accurate pricing and delivery options + are displayed to customers. """ buyerIdentity: BuyerIdentity """ - The costs that the buyer will pay at checkout. + A breakdown of the costs that the customer will pay at checkout. It includes the total amount, + the subtotal before taxes and duties, the tax amount, and duty charges. """ cost: CartCost! """ - A list of lines containing information about the items that can be delivered. + The items in a cart that are eligible for fulfillment and can be delivered to the customer. """ deliverableLines: [DeliverableCartLine!]! """ - The delivery groups available for the cart based on the buyer's shipping address. + A collection of items that are grouped by shared delivery characteristics. Delivery groups streamline + fulfillment by organizing items that can be shipped together, based on the customer's + shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped + together, then the items are included in the same delivery group. """ deliveryGroups: [CartDeliveryGroup!]! """ - A list of lines containing information about the items the customer intends to purchase. + The items in a cart that the customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ lines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The localized fields available for the cart. + The additional fields on the **Cart** page that are required for international orders in specific countries, + such as customs information or tax identification numbers. """ localizedFields( """ @@ -133,113 +165,140 @@ type Cart { } """ -The cost that the buyer will pay at checkout. +A breakdown of the costs that the customer will pay at checkout. It includes the total amount, +the subtotal before taxes and duties, the tax amount, and duty charges. """ type CartCost { """ - The amount, before taxes and discounts, for the customer to pay. + The amount for the customer to pay at checkout, excluding taxes and discounts. """ subtotalAmount: MoneyV2! """ - The total amount for the customer to pay. + The total amount for the customer to pay at checkout. """ totalAmount: MoneyV2! """ - The duty amount for the customer to pay at checkout. + The duty charges for a customer to pay at checkout. """ totalDutyAmount: MoneyV2 """ - The tax amount for the customer to pay at checkout. + The total tax amount for the customer to pay at checkout. """ totalTaxAmount: MoneyV2 } """ -Information about the options available for one or more line items to be delivered to a specific address. +Information about items in a cart that are grouped by shared delivery characteristics. +Delivery groups streamline fulfillment by organizing items that can be shipped together, based on the customer's +shipping address. For example, if a customer orders a t-shirt and a pair of shoes that can be shipped +together, then the items are included in the same delivery group. """ type CartDeliveryGroup { """ - A list of cart lines for the delivery group. + Information about items in a cart that a customer intends to purchase. A cart line is an entry in the + customer's cart that represents a single unit of a product variant. For example, if a customer adds two + different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ cartLines: [CartLine!]! @scaleLimits(rate: 0.005) """ - The destination address for the delivery group. + The shipping or destination address associated with the delivery group. """ deliveryAddress: MailingAddress """ - The delivery options available for the delivery group. + The delivery options available for the delivery group. Delivery options are the different ways that customers + can choose to have their orders shipped. Examples include express shipping or standard shipping. """ deliveryOptions: [CartDeliveryOption!]! """ - Unique identifier for the delivery group. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the delivery group. """ id: ID! """ - Information about the delivery option the buyer has selected. + Information about the delivery option that the customer has selected. """ selectedDeliveryOption: CartDeliveryOption } """ -Information about a delivery option. +Information about a delivery option that's available for an item in a cart. Delivery options are the different +ways that customers can choose to have their orders shipped. Examples include express shipping or standard +shipping. """ type CartDeliveryOption { """ - The code of the delivery option. + A unique identifier that represents the delivery option offered to customers. + For example, `Canada Post Expedited`. """ code: String """ - The cost for the delivery option. + The amount that the customer pays if they select the delivery option. """ cost: MoneyV2! """ - The method for the delivery option. + The delivery method associated with the delivery option. A delivery method is a way that merchants can + fulfill orders from their online stores. Delivery methods include shipping to an address, + [local pickup](https://help.shopify.com/manual/fulfillment/setup/delivery-methods/pickup-in-store), + and shipping to a [pickup point](https://help.shopify.com/manual/fulfillment/shopify-shipping/pickup-points), + all of which are natively supported by Shopify checkout. """ deliveryMethodType: DeliveryMethod! """ - The description of the delivery option. + A single-line description of the delivery option, with HTML tags removed. """ description: String """ - The unique identifier of the delivery option. + A unique, human-readable identifier of the delivery option's title. + A handle can contain letters, hyphens (`-`), and numbers, but not spaces. + For example, `standard-shipping`. """ handle: Handle! """ - The title of the delivery option. + The name of the delivery option that displays to customers. The title is used to construct the delivery + option's handle. For example, if a delivery option is titled "Standard Shipping", then the handle is + `standard-shipping`. """ title: String } """ -Represents information about the merchandise in the cart. +Information about an item in a cart that a customer intends to purchase. A cart line is an entry in the +customer's cart that represents a single unit of a product variant. For example, if a customer adds two +different sizes of the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute """ - The cost of the merchandise line that the buyer will pay at checkout. + The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's + cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of + the same t-shirt to their cart, then each size is represented as a separate cart line. """ cost: CartLineCost! @@ -249,59 +308,92 @@ type CartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! """ - The selling plan associated with the cart line and the effect that each - selling plan has on variants when they're purchased. + The [selling plan](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + associated with the cart line, including information about how a product variant can be sold and purchased. """ sellingPlanAllocation: SellingPlanAllocation } """ -The cost of the merchandise line that the buyer will pay at checkout. +The cost of an item in a cart that the customer intends to purchase. Cart lines are entries in the customer's +cart that represent a single unit of a product variant. For example, if a customer adds two different sizes of +the same t-shirt to their cart, then each size is represented as a separate cart line. """ type CartLineCost { """ - The amount of the merchandise line. + The cost of a single unit. For example, if a customer purchases three units of a product + that are priced at $10 each, then the `amountPerQuantity` is $10. """ amountPerQuantity: MoneyV2! """ - The compare at amount of the merchandise line. This value varies depending on - the buyer's identity, and is null when the value is hidden to buyers. + The cost of a single unit before any discounts are applied. This field is used to calculate and display + savings for customers. For example, if a product's `compareAtAmountPerQuantity` is $25 and its current price + is $20, then the customer sees a $5 discount. This value can change based on the buyer's identity and is + `null` when the value is hidden from buyers. """ compareAtAmountPerQuantity: MoneyV2 """ - The cost of the merchandise line before line-level discounts. + The cost of items in the cart before applying any discounts to certain items. + This amount serves as the starting point for calculating any potential savings customers + might receive through promotions or discounts. """ subtotalAmount: MoneyV2! """ - The total cost of the merchandise line. + The total cost of items in a cart. """ totalAmount: MoneyV2! } """ -Represents whether the product is a member of the given collection. +The fetch target result. Your Function must return this data structure when generating the request. +""" +input CartValidationsGenerateFetchResult { + """ + The attributes associated with an HTTP request. + """ + request: HttpRequest +} + +""" +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. +""" +input CartValidationsGenerateRunResult { + """ + The ordered list of operations to apply. + """ + operations: [Operation!]! +} + +""" +Whether the product is in the specified collection. + +A collection is a group of products that can be displayed in online stores and other sales channels in +categories, which makes it easy for customers to find them. For example, an athletics store might create +different collections for running attire and accessories. """ type CollectionMembership { """ - The ID of the collection. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the collection. """ collectionId: ID! """ - Whether the product is a member of the collection. + Whether the product is in the specified collection. """ isMember: Boolean! } @@ -326,16 +418,24 @@ type Company implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -409,16 +509,24 @@ type CompanyLocation implements HasMetafields { locale: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -436,7 +544,9 @@ type CompanyLocation implements HasMetafields { } """ -A country. +The country for which the store is customized, reflecting local preferences and regulations. +Localization might influence the language, currency, and product offerings available in a store to enhance +the shopping experience for customers in that region. """ type Country { """ @@ -1679,9 +1789,8 @@ enum CountryCode { } """ -The three-letter currency codes that represent the world currencies used in -stores. These include standard ISO 4217 codes, legacy codes, -and non-standard codes. +The three-letter currency codes that represent the world currencies used in stores. Currency codes include +[standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, and non-standard codes. """ enum CurrencyCode { """ @@ -2491,7 +2600,10 @@ enum CurrencyCode { } """ -A custom product. +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ type CustomProduct { """ @@ -2500,43 +2612,51 @@ type CustomProduct { isGiftCard: Boolean! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents a customer with the shop. +Represents a [customer](https://help.shopify.com/manual/customers/manage-customers) +who has an [account](https://help.shopify.com/manual/customers/customer-accounts) with the store. +`Customer` returns data including the customer's contact information and order history. """ type Customer implements HasMetafields { """ - The total amount of money spent by the customer. Converted from the shop's - currency to the currency of the cart using a market rate. + The total amount that the customer has spent on orders. + The amount is converted from the shop's currency to the currency of the cart using a market rate. """ amountSpent: MoneyV2! """ - The customer’s name, email or phone number. + The full name of the customer, based on the values for `firstName` and `lastName`. + If `firstName` and `lastName` aren't specified, then the value is the customer's email address. + If the email address isn't specified, then the value is the customer's phone number. """ displayName: String! """ - The customer’s email address. + The customer's email address. """ email: String @@ -2546,27 +2666,32 @@ type Customer implements HasMetafields { firstName: String """ - Whether the customer has any of the given tags. + Whether the customer is associated with any of the specified tags. The customer must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to search for. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with either the `VIP` or `Gold` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the customer has the given tags. + Whether the customer is associated with the specified tags. The customer must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the customer. For example, + `"VIP, Gold"` returns customers with both the `VIP` and `Gold` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A unique identifier for the customer. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the customer. """ id: ID! @@ -2576,22 +2701,30 @@ type Customer implements HasMetafields { lastName: String """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The number of orders made by the customer. + The total number of orders that the customer has made at the store. """ numberOfOrders: Int! } @@ -2629,13 +2762,17 @@ Represents information about the merchandise in the cart. """ type DeliverableCartLine { """ - Retrieve a cart line attribute by key. + The custom attributes associated with a cart to store additional information. Cart attributes + allow you to collect specific information from customers on the **Cart** page, such as order notes, + gift wrapping requests, or custom product details. Attributes are stored as key-value pairs. - Cart line attributes are also known as line item properties in Liquid. + Cart line attributes are equivalent to the + [`line_item`](https://shopify.dev/docs/apps/build/purchase-options/subscriptions/selling-plans) + object in Liquid. """ attribute( """ - The key of the attribute to retrieve. + The key of the cart attribute to retrieve. For example, `"gift_wrapping"`. """ key: String ): Attribute @@ -2646,12 +2783,12 @@ type DeliverableCartLine { id: ID! """ - The merchandise that the buyer intends to purchase. + The item that the customer intends to purchase. """ merchandise: Merchandise! """ - The quantity of the merchandise that the customer intends to purchase. + The quantity of the item that the customer intends to purchase. """ quantity: Int! } @@ -2701,37 +2838,42 @@ input FunctionError { localizedMessage: String! """ - Specifies the path/target for use by the UI. + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. """ target: String! } """ -The fetch target result. Refer to network access for Shopify Functions. +The fetch target result. Your Function must return this data structure when generating the request. """ input FunctionFetchResult { """ - HTTP Request. + The attributes associated with an HTTP request. """ request: HttpRequest } """ -The run target result. In API versions 2023-10 and beyond, this type is deprecated in favor of `FunctionRunResult`. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. In +API versions 2023-10 and beyond, this type is deprecated in favor of +`FunctionRunResult`. """ input FunctionResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } """ -The run target result. +The output of the Function run target. The object contains the validation errors +that display to customers and prevent them from proceeding through checkout. """ input FunctionRunResult { """ - Errors. + The validation errors that block a customer from proceeding through checkout. """ errors: [FunctionError!]! } @@ -2748,32 +2890,42 @@ Represents information about the metafields associated to the specified resource """ interface HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } """ -Represents whether the current object has the given tag. +Whether a Shopify resource, such as a product or customer, has a specified tag. """ type HasTagResponse { """ - Whether the current object has the tag. + Whether the Shopify resource has the tag. """ hasTag: Boolean! """ - The tag. + A searchable keyword that's associated with a Shopify resource, such as a product or customer. For example, + a merchant might apply the `sports` and `summer` tags to products that are associated with sportswear for + summer. """ tag: String! } @@ -2886,9 +3038,9 @@ type HttpResponse { headers: [HttpResponseHeader!]! @deprecated(reason: "Use `header` instead.") """ - The HTTP response body parsed as JSON. - If the body is valid JSON, it will be parsed and returned as a JSON object. - If parsing fails, then raw body is returned as a string. + The HTTP response body parsed as JSON. + If the body is valid JSON, it will be parsed and returned as a JSON object. + If parsing fails, then raw body is returned as a string. Use this field when you expect the response to be JSON, or when you're dealing with mixed response types, meaning both JSON and non-JSON. Using this field reduces function instruction consumption and ensures that the data is formatted in logs. @@ -2926,39 +3078,63 @@ Example value: `"gid://shopify/Product/10079785100"` """ scalar ID +""" +The `Input` object is the complete GraphQL schema that your Function can receive +as input to validate cart and checkout. Your Function receives only the fields +that you request in the input query. To optimize performance, we highly +recommend that you request only the fields that your Function requires. +""" type Input { """ - The buyer journey step. + Information about the current step in the buyer's purchasing process. The + buyer journey helps you determine where the customer is in their shopping + experience (for example, cart interaction, checkout interaction, or completing + a checkout). You can use this information to apply appropriate validation + rules based on the customer's current context and create a more tailored and + performant shopping experience. """ buyerJourney: BuyerJourney! """ - The cart. + The cart where the Function is running. A cart contains the merchandise that a customer intends to purchase + and information about the customer, such as the customer's email address and phone number. """ cart: Cart! """ - The result of the fetch target. Refer to network access for Shopify Functions. + The `FunctionFetchResult` object is the result of the fetch target. This is + the response that Shopify returns after executing the HTTP request defined in + your fetch target, and that is passed as input to the run target. For more + information, refer to [network access for Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/network-access). """ - fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run"]) + fetchResult: HttpResponse @restrictTarget(only: ["purchase.validation.run", "cart.validations.generate.run"]) """ - The localization of the Function execution context. + The regional and language settings that determine how the Function + handles currency, numbers, dates, and other locale-specific values + during discount calculations. These settings are based on the store's configured + [localization practices](https://shopify.dev/docs/apps/build/functions/localization-practices-shopify-functions). """ localization: Localization! """ - The conversion rate between the shop's currency and the currency of the cart. + The exchange rate used to convert discounts between the shop's default + currency and the currency that displays to the customer during checkout. + For example, if a store operates in USD but a customer is viewing discounts in EUR, + then the presentment currency rate handles this conversion for accurate pricing. """ presentmentCurrencyRate: Decimal! """ - Information about the shop. + Information about the shop where the Function is running, including the shop's timezone + setting and associated [metafields](https://shopify.dev/docs/apps/build/custom-data). """ shop: Shop! """ - The validation rule that owns the current function. + The configuration of the app that owns the Function. This configuration + controls how merchants can define validation rules for carts and checkout, + such as inventory checks, price validations, or custom purchase restrictions. """ validation: Validation! } @@ -2981,7 +3157,8 @@ Example value: scalar JSON """ -A language. +The language for which the store is customized, ensuring content is tailored to local customers. +This includes product descriptions and customer communications that resonate with the target audience. """ type Language { """ @@ -3701,7 +3878,8 @@ enum LanguageCode { } """ -Represents limited information about the current time relative to the parent object. +The current time based on the +[store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ type LocalTime { """ @@ -3781,23 +3959,29 @@ type LocalTime { } """ -Information about the localized experiences configured for the shop. +Details about the localized experience for the store in a specific region, including country and language +settings. The localized experience is determined by the store's settings and the customer's location. +Localization ensures that customers can access relevant content and options while browsing or purchasing +products in a store. """ type Localization { """ - The country of the active localized experience. + The country for which the store is customized, reflecting local preferences and regulations. + Localization might influence the language, currency, and product offerings available in a store to enhance + the shopping experience for customers in that region. """ country: Country! """ - The language of the active localized experience. + The language for which the store is customized, ensuring content is tailored to local customers. + This includes product descriptions and customer communications that resonate with the target audience. """ language: Language! """ The market of the active localized experience. """ - market: Market! + market: Market! @deprecated(reason: "This `market` field will be removed in a future version of the API.") } """ @@ -3828,187 +4012,187 @@ Unique key identifying localized fields. """ enum LocalizedFieldKey { """ - Localized field key 'shipping_credential_br' for country BR. + Localized field key 'shipping_credential_br' for country Brazil. """ SHIPPING_CREDENTIAL_BR """ - Localized field key 'shipping_credential_cl' for country CL. + Localized field key 'shipping_credential_cl' for country Chile. """ SHIPPING_CREDENTIAL_CL """ - Localized field key 'shipping_credential_cn' for country CN. + Localized field key 'shipping_credential_cn' for country China. """ SHIPPING_CREDENTIAL_CN """ - Localized field key 'shipping_credential_co' for country CO. + Localized field key 'shipping_credential_co' for country Colombia. """ SHIPPING_CREDENTIAL_CO """ - Localized field key 'shipping_credential_cr' for country CR. + Localized field key 'shipping_credential_cr' for country Costa Rica. """ SHIPPING_CREDENTIAL_CR """ - Localized field key 'shipping_credential_ec' for country EC. + Localized field key 'shipping_credential_ec' for country Ecuador. """ SHIPPING_CREDENTIAL_EC """ - Localized field key 'shipping_credential_es' for country ES. + Localized field key 'shipping_credential_es' for country Spain. """ SHIPPING_CREDENTIAL_ES """ - Localized field key 'shipping_credential_gt' for country GT. + Localized field key 'shipping_credential_gt' for country Guatemala. """ SHIPPING_CREDENTIAL_GT """ - Localized field key 'shipping_credential_id' for country ID. + Localized field key 'shipping_credential_id' for country Indonesia. """ SHIPPING_CREDENTIAL_ID """ - Localized field key 'shipping_credential_kr' for country KR. + Localized field key 'shipping_credential_kr' for country South Korea. """ SHIPPING_CREDENTIAL_KR """ - Localized field key 'shipping_credential_mx' for country MX. + Localized field key 'shipping_credential_mx' for country Mexico. """ SHIPPING_CREDENTIAL_MX """ - Localized field key 'shipping_credential_my' for country MY. + Localized field key 'shipping_credential_my' for country Malaysia. """ SHIPPING_CREDENTIAL_MY """ - Localized field key 'shipping_credential_pe' for country PE. + Localized field key 'shipping_credential_pe' for country Peru. """ SHIPPING_CREDENTIAL_PE """ - Localized field key 'shipping_credential_pt' for country PT. + Localized field key 'shipping_credential_pt' for country Portugal. """ SHIPPING_CREDENTIAL_PT """ - Localized field key 'shipping_credential_py' for country PY. + Localized field key 'shipping_credential_py' for country Paraguay. """ SHIPPING_CREDENTIAL_PY """ - Localized field key 'shipping_credential_tr' for country TR. + Localized field key 'shipping_credential_tr' for country Turkey. """ SHIPPING_CREDENTIAL_TR """ - Localized field key 'shipping_credential_tw' for country TW. + Localized field key 'shipping_credential_tw' for country Taiwan. """ SHIPPING_CREDENTIAL_TW """ - Localized field key 'shipping_credential_type_co' for country CO. + Localized field key 'shipping_credential_type_co' for country Colombia. """ SHIPPING_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_br' for country BR. + Localized field key 'tax_credential_br' for country Brazil. """ TAX_CREDENTIAL_BR """ - Localized field key 'tax_credential_cl' for country CL. + Localized field key 'tax_credential_cl' for country Chile. """ TAX_CREDENTIAL_CL """ - Localized field key 'tax_credential_co' for country CO. + Localized field key 'tax_credential_co' for country Colombia. """ TAX_CREDENTIAL_CO """ - Localized field key 'tax_credential_cr' for country CR. + Localized field key 'tax_credential_cr' for country Costa Rica. """ TAX_CREDENTIAL_CR """ - Localized field key 'tax_credential_ec' for country EC. + Localized field key 'tax_credential_ec' for country Ecuador. """ TAX_CREDENTIAL_EC """ - Localized field key 'tax_credential_es' for country ES. + Localized field key 'tax_credential_es' for country Spain. """ TAX_CREDENTIAL_ES """ - Localized field key 'tax_credential_gt' for country GT. + Localized field key 'tax_credential_gt' for country Guatemala. """ TAX_CREDENTIAL_GT """ - Localized field key 'tax_credential_id' for country ID. + Localized field key 'tax_credential_id' for country Indonesia. """ TAX_CREDENTIAL_ID """ - Localized field key 'tax_credential_it' for country IT. + Localized field key 'tax_credential_it' for country Italy. """ TAX_CREDENTIAL_IT """ - Localized field key 'tax_credential_mx' for country MX. + Localized field key 'tax_credential_mx' for country Mexico. """ TAX_CREDENTIAL_MX """ - Localized field key 'tax_credential_my' for country MY. + Localized field key 'tax_credential_my' for country Malaysia. """ TAX_CREDENTIAL_MY """ - Localized field key 'tax_credential_pe' for country PE. + Localized field key 'tax_credential_pe' for country Peru. """ TAX_CREDENTIAL_PE """ - Localized field key 'tax_credential_pt' for country PT. + Localized field key 'tax_credential_pt' for country Portugal. """ TAX_CREDENTIAL_PT """ - Localized field key 'tax_credential_py' for country PY. + Localized field key 'tax_credential_py' for country Paraguay. """ TAX_CREDENTIAL_PY """ - Localized field key 'tax_credential_tr' for country TR. + Localized field key 'tax_credential_tr' for country Turkey. """ TAX_CREDENTIAL_TR """ - Localized field key 'tax_credential_type_co' for country CO. + Localized field key 'tax_credential_type_co' for country Colombia. """ TAX_CREDENTIAL_TYPE_CO """ - Localized field key 'tax_credential_type_mx' for country MX. + Localized field key 'tax_credential_type_mx' for country Mexico. """ TAX_CREDENTIAL_TYPE_MX """ - Localized field key 'tax_credential_use_mx' for country MX. + Localized field key 'tax_credential_use_mx' for country Mexico. """ TAX_CREDENTIAL_USE_MX """ - Localized field key 'tax_email_it' for country IT. + Localized field key 'tax_email_it' for country Italy. """ TAX_EMAIL_IT } @@ -4065,7 +4249,7 @@ type MailingAddress { """ The market of the address. """ - market: Market + market: Market @deprecated(reason: "This `market` field will be removed in a future version of the API.") """ The full name of the customer, based on firstName and lastName. @@ -4108,16 +4292,24 @@ type Market implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4154,47 +4346,60 @@ type MarketRegionCountry implements MarketRegion { } """ -The merchandise to be purchased at checkout. +The item that a customer intends to purchase. Merchandise can be a product variant or a custom +product. + +A product variant is a specific version of a product that comes in more than one option, such as size or color. +For example, if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be +one product variant and a large, blue t-shirt would be another. + +A custom product represents a product that doesn't map to Shopify's +[standard product categories](https://help.shopify.com/manual/products/details/product-type). +For example, you can use a custom product to manage gift cards, shipping requirements, localized product +information, or weight measurements and conversions. """ union Merchandise = CustomProduct | ProductVariant """ -[Metafields](https://shopify.dev/apps/metafields) -enable you to attach additional information to a -Shopify resource, such as a [Product](https://shopify.dev/api/admin-graphql/latest/objects/product) -or a [Collection](https://shopify.dev/api/admin-graphql/latest/objects/collection). -For more information about the Shopify resources that you can attach metafields to, refer to -[HasMetafields](https://shopify.dev/api/admin/graphql/reference/common-objects/HasMetafields). +[Custom fields](https://shopify.dev/docs/apps/build/custom-data) that store additional information +about a Shopify resource, such as products, orders, and +[many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). +Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) +enables you to customize the checkout experience. """ type Metafield { """ - The data stored in the metafield in JSON format. + The data that's stored in the metafield, using JSON format. """ jsonValue: JSON! """ - The type of data that the metafield stores in the `value` field. - Refer to the list of [supported types](https://shopify.dev/apps/metafields/types). + The [type of data](https://shopify.dev/apps/metafields/types) that the metafield stores in + the `value` field. """ type: String! """ - The data stored in the metafield. Always stored as a string, regardless of the metafield's type. + The data that's stored in the metafield. The data is always stored as a string, + regardless of the [metafield's type](https://shopify.dev/apps/metafields/types). """ value: String! } """ -A monetary value with currency. +A precise monetary value and its associated currency. For example, 12.99 USD. """ type MoneyV2 { """ - Decimal money amount. + A monetary value in decimal format, allowing for precise representation of cents or fractional + currency. For example, 12.99. """ amount: Decimal! """ - Currency of the money. + The three-letter currency code that represents a world currency used in a store. Currency codes + include standard [standard ISO 4217 codes](https://en.wikipedia.org/wiki/ISO_4217), legacy codes, + and non-standard codes. For example, USD. """ currencyCode: CurrencyCode! } @@ -4203,6 +4408,26 @@ type MoneyV2 { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.validations.generate.fetch target. + """ + cartValidationsGenerateFetch( + """ + The result of the Function. + """ + result: CartValidationsGenerateFetchResult! + ): Void! + + """ + Handles the Function result for the cart.validations.generate.run target. + """ + cartValidationsGenerateRun( + """ + The result of the Function. + """ + result: CartValidationsGenerateRunResult! + ): Void! + """ Handles the Function result for the purchase.validation.fetch target. """ @@ -4235,55 +4460,88 @@ type MutationRoot { } """ -Represents a product. +An operation to apply. +""" +input Operation @oneOf { + """ + Add a performed validation. + """ + validationAdd: ValidationAddOperation +} + +""" +The goods and services that merchants offer to customers. Products can include details such as +title, vendor, and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). +Products can be organized by grouping them into a collection. + +Learn more about [managing products in a merchant's store](https://help.shopify.com/manual/products). """ type Product implements HasMetafields { """ - A unique human-friendly string of the product's title. + A unique, human-readable string of the product's title. A handle can contain letters, hyphens (`-`), and + numbers, but not spaces. The handle is used in the online store URL for the product. For example, if a product + is titled "Black Sunglasses", then the handle is `black-sunglasses`. """ handle: Handle! """ - Whether the product has any of the given tags. + Whether the product is associated with any of the specified tags. The product must have at least one tag + from the list to return `true`. """ hasAnyTag( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with either the `sports` or `summer` tag. """ tags: [String!]! = [] ): Boolean! """ - Whether the product has the given tags. + Whether the product is associated with the specified tags. The product must have all of the tags in the list + to return `true`. """ hasTags( """ - The tags to check. + A comma-separated list of searchable keywords that are associated with the product. For example, + `"sports, summer"` returns products with both the `sports` and `summer` tags. """ tags: [String!]! = [] ): [HasTagResponse!]! """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product. """ id: ID! """ - Whether the product is in any of the given collections. + Whether the product is in any of the specified collections. The product must be in at least one collection + from the list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inAnyCollection( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): Boolean! """ - Whether the product is in the given collections. + Whether the product is in the specified collections. The product must be in all of the collections in the + list to return `true`. + + A collection is a group of products that can be displayed in online stores and other sales channels in + categories, which makes it easy for customers to find them. For example, an athletics store might create + different collections for running attire and accessories. """ inCollections( """ - The IDs of the collections to check. + A comma-separated list of [globally-unique collection IDs](https://shopify.dev/docs/api/usage/gids) + that are associated with the product. For example, `gid://shopify/Collection/123`, `gid://shopify/Collection/456`. """ ids: [ID!]! = [] ): [CollectionMembership!]! @@ -4294,27 +4552,39 @@ type Product implements HasMetafields { isGiftCard: Boolean! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product type specified by the merchant. + A custom category for a product. Product types allow merchants to define categories other than the + ones available in Shopify's + [standard product categories](https://help.shopify.com/manual/products/details/product-type). """ productType: String """ - The localized title of the product in the customer’s locale. + The localized name for the product that displays to customers. The title is used to construct the product's + handle, which is a unique, human-readable string of the product's title. For example, if a product is titled + "Black Sunglasses", then the handle is `black-sunglasses`. """ title: String! @@ -4325,62 +4595,81 @@ type Product implements HasMetafields { } """ -Represents a product variant. +A specific version of a product that comes in more than one option, such as size or color. For example, +if a merchant sells t-shirts with options for size and color, then a small, blue t-shirt would be one +product variant and a large, blue t-shirt would be another. """ type ProductVariant implements HasMetafields { """ - A globally-unique identifier. + A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) + for the product variant. """ id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield """ - The product that this variant belongs to. + The product associated with the product variant. For example, if a + merchant sells t-shirts with options for size and color, then a small, + blue t-shirt would be one product variant and a large, blue t-shirt would be another. + The product associated with the product variant would be the t-shirt itself. """ product: Product! """ - Whether the merchandise requires shipping. + Whether the item needs to be shipped to the customer. For example, a + digital gift card doesn't need to be shipped, but a t-shirt does + need to be shipped. """ requiresShipping: Boolean! """ - An identifier for the product variant in the shop. Required in order to connect to a fulfillment service. + A case-sensitive identifier for the product variant in the merchant's store. For example, `"BBC-1"`. + A product variant must have a SKU to be connected to a + [fulfillment service](https://shopify.dev/docs/apps/build/orders-fulfillment/fulfillment-service-apps/build-for-fulfillment-services). """ sku: String """ - The localized title of the product variant in the customer’s locale. + The localized name for the product variant that displays to customers. """ title: String """ - The weight of the product variant in the unit system specified with `weight_unit`. + The product variant's weight, in the system of measurement set in the `weightUnit` field. """ weight: Float """ - Unit of measurement for weight. + The unit of measurement for weight. """ weightUnit: WeightUnit! } """ -Represents information about the buyer that is interacting with the cart. +The company of a B2B customer that's interacting with the cart. +Used to manage and track purchases made by businesses rather than individual customers. """ type PurchasingCompany { """ @@ -4414,16 +4703,24 @@ type SellingPlan implements HasMetafields { id: ID! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4483,25 +4780,35 @@ type SellingPlanAllocationPriceAdjustment { } """ -Information about the shop. +Information about the store, including the store's timezone setting +and custom data stored in [metafields](https://shopify.dev/docs/apps/build/custom-data). """ type Shop implements HasMetafields { """ - Information about the current time relative to the shop's timezone setting. + The current time based on the + [store's timezone setting](https://help.shopify.com/manual/intro-to-shopify/initial-setup/setup-business-settings). """ localTime: LocalTime! """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield @@ -4528,21 +4835,55 @@ A customization that validates a cart and/or checkout. """ type Validation implements HasMetafields { """ - Returns a metafield by namespace and key that belongs to the resource. + A [custom field](https://shopify.dev/docs/apps/build/custom-data) that stores additional information + about a Shopify resource, such as products, orders, and + [many more](https://shopify.dev/docs/api/admin-graphql/latest/enums/MetafieldOwnerType). + Using [metafields with Shopify Functions](https://shopify.dev/docs/apps/build/functions/input-output/metafields-for-input-queries) + enables you to customize the checkout experience. """ metafield( """ - The key for the metafield. + The unique identifier for the metafield within its namespace. A metafield is composed of a + namespace and a key, in the format `namespace.key`. """ key: String! """ - The container the metafield belongs to. If omitted, the app-reserved namespace will be used. + A category that organizes a group of metafields. Namespaces are used to prevent naming conflicts + between different apps or different parts of the same app. If omitted, then the + [app-reserved namespace](https://shopify.dev/docs/apps/build/custom-data/ownership) + is used. """ namespace: String ): Metafield } +""" +Add a performed validation. +""" +input ValidationAddOperation { + """ + Errors. + """ + errors: [ValidationError!]! +} + +""" +A Function error for a path. +""" +input ValidationError { + """ + Returns a message describing the error. + """ + message: String! + + """ + Specifies the path/target for use by the UI. See [Supported checkout field targets](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + for a list of supported targets. + """ + target: String! +} + """ A void type that can be used to return a null value from a mutation. """ diff --git a/checkout/wasm/cart-checkout-validation/default/shopify.extension.toml.liquid b/checkout/wasm/cart-checkout-validation/default/shopify.extension.toml.liquid index d3b1f766..056279ed 100644 --- a/checkout/wasm/cart-checkout-validation/default/shopify.extension.toml.liquid +++ b/checkout/wasm/cart-checkout-validation/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,7 +8,7 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.validation.run" + target = "cart.validations.generate.run" input_query = "run.graphql" export = "run" @@ -16,4 +16,3 @@ description = "t:description" command = "echo 'build the wasm'" path = "" watch = [] -