From efb36973c09712eea3e9b0a357ac06475021221a Mon Sep 17 00:00:00 2001 From: Martin Gingras Date: Mon, 28 Apr 2025 15:35:47 -0400 Subject: [PATCH 1/3] Update Payment Customization function templates --- .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- ...ment_methods_transform_run.graphql.liquid} | 2 +- .../cart_payment_methods_transform_run.liquid | 45 ++++++ ...payment_methods_transform_run.test.liquid} | 16 +- .../default/src/index.liquid | 2 +- .../default/src/run.liquid | 45 ------ .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- ...ment_methods_transform_run.graphql.liquid} | 0 ... => cart_payment_methods_transform_run.rs} | 14 +- .../payment-customization/default/src/main.rs | 2 +- ...ment_methods_transform_run.graphql.liquid} | 0 .../default/schema.graphql | 138 +++++++++++++++++- .../default/shopify.extension.toml.liquid | 8 +- 15 files changed, 468 insertions(+), 96 deletions(-) rename checkout/javascript/payment-customization/default/src/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (78%) create mode 100644 checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid rename checkout/javascript/payment-customization/default/src/{run.test.liquid => cart_payment_methods_transform_run.test.liquid} (50%) delete mode 100644 checkout/javascript/payment-customization/default/src/run.liquid rename checkout/rust/payment-customization/default/src/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (100%) rename checkout/rust/payment-customization/default/src/{run.rs => cart_payment_methods_transform_run.rs} (64%) rename checkout/wasm/payment-customization/default/{run.graphql.liquid => cart_payment_methods_transform_run.graphql.liquid} (100%) diff --git a/checkout/javascript/payment-customization/default/schema.graphql b/checkout/javascript/payment-customization/default/schema.graphql index 306aa01b..298d9cd7 100644 --- a/checkout/javascript/payment-customization/default/schema.graphql +++ b/checkout/javascript/payment-customization/default/schema.graphql @@ -335,6 +335,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2791,6 +2802,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2800,7 +2850,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2810,7 +2860,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3785,7 +3835,7 @@ type Localization { """ 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.") } """ @@ -4053,7 +4103,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. @@ -4233,6 +4283,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4267,7 +4327,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4278,7 +4338,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4290,7 +4350,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4356,6 +4416,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ 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). diff --git a/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid b/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid index 6edc9611..9c7b6440 100644 --- a/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/javascript/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "src/run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "src/cart_payment_methods_transform_run.graphql" + export = "cart-payment-methods-transform-run" [extensions.build] command = "" diff --git a/checkout/javascript/payment-customization/default/src/run.graphql.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid similarity index 78% rename from checkout/javascript/payment-customization/default/src/run.graphql.liquid rename to checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid index 8628f963..0969f408 100644 --- a/checkout/javascript/payment-customization/default/src/run.graphql.liquid +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid @@ -1,4 +1,4 @@ -query RunInput { +query CartPaymentMethodsTransformRunInput { paymentCustomization { metafield(namespace: "$app:{{handle | replace: " ", "-" | downcase}}", key: "function-configuration") { value diff --git a/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid new file mode 100644 index 00000000..01e5a642 --- /dev/null +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.liquid @@ -0,0 +1,45 @@ +{%- if flavor contains "vanilla-js" -%} +// @ts-check + +/** + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunInput} CartPaymentMethodsTransformRunInput + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunResult} CartPaymentMethodsTransformRunResult + */ + +/** + * @type {CartPaymentMethodsTransformRunResult} + */ +const NO_CHANGES = { + operations: [], +}; + +/** + * @param {CartPaymentMethodsTransformRunInput} input + * @returns {CartPaymentMethodsTransformRunResult} + */ +export function cartPaymentMethodsTransformRun(input) { + const configuration = JSON.parse( + input?.paymentCustomization?.metafield?.value ?? "{}" + ); + + return NO_CHANGES; +}; +{%- elsif flavor contains "typescript" -%} +import type { + CartPaymentMethodsTransformRunInput, + CartPaymentMethodsTransformRunResult, +} from "../generated/api"; + +const NO_CHANGES: CartPaymentMethodsTransformRunResult = { + operations: [], +}; + +type Configuration = {}; + +export function cartPaymentMethodsTransformRun(input: CartPaymentMethodsTransformRunInput): CartPaymentMethodsTransformRunResult { + const configuration: Configuration = JSON.parse( + input?.paymentCustomization?.metafield?.value ?? "{}" + ); + return NO_CHANGES; +}; +{%- endif -%} diff --git a/checkout/javascript/payment-customization/default/src/run.test.liquid b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid similarity index 50% rename from checkout/javascript/payment-customization/default/src/run.test.liquid rename to checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid index 894d036e..15e66eb0 100644 --- a/checkout/javascript/payment-customization/default/src/run.test.liquid +++ b/checkout/javascript/payment-customization/default/src/cart_payment_methods_transform_run.test.liquid @@ -1,36 +1,36 @@ {%- if flavor contains "vanilla-js" -%} import { describe, it, expect } from 'vitest'; -import { run } from './run'; +import { cartPaymentMethodsTransformRun } from './cart_payment_methods_transform_run'; /** - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult + * @typedef {import("../generated/api").CartPaymentMethodsTransformRunResult} CartPaymentMethodsTransformRunResult */ describe('payment customization function', () => { it('returns no operations without configuration', () => { - const result = run({ + const result = cartPaymentMethodsTransformRun({ paymentCustomization: { metafield: null } }); - const expected = /** @type {FunctionRunResult} */ ({ operations: [] }); + const expected = /** @type {CartPaymentMethodsTransformRunResult} */ ({ operations: [] }); expect(result).toEqual(expected); }); }); {%- elsif flavor contains "typescript" -%} import { describe, it, expect } from 'vitest'; -import { run } from './run'; -import { FunctionRunResult } from '../generated/api'; +import { cartPaymentMethodsTransformRun } from './cart_payment_methods_transform_run'; +import { CartPaymentMethodsTransformRunResult } from '../generated/api'; describe('payment customization function', () => { it('returns no operations without configuration', () => { - const result = run({ + const result = cartPaymentMethodsTransformRun({ paymentCustomization: { metafield: null } }); - const expected: FunctionRunResult = { operations: [] }; + const expected: CartPaymentMethodsTransformRunResult = { operations: [] }; expect(result).toEqual(expected); }); diff --git a/checkout/javascript/payment-customization/default/src/index.liquid b/checkout/javascript/payment-customization/default/src/index.liquid index 2e6f9676..6da48efe 100644 --- a/checkout/javascript/payment-customization/default/src/index.liquid +++ b/checkout/javascript/payment-customization/default/src/index.liquid @@ -1 +1 @@ -export * from './run'; +export * from './cart_payment_methods_transform_run'; diff --git a/checkout/javascript/payment-customization/default/src/run.liquid b/checkout/javascript/payment-customization/default/src/run.liquid deleted file mode 100644 index 8c6d24ab..00000000 --- a/checkout/javascript/payment-customization/default/src/run.liquid +++ /dev/null @@ -1,45 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check - -/** - * @typedef {import("../generated/api").RunInput} RunInput - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult - */ - -/** - * @type {FunctionRunResult} - */ -const NO_CHANGES = { - operations: [], -}; - -/** - * @param {RunInput} input - * @returns {FunctionRunResult} - */ -export function run(input) { - const configuration = JSON.parse( - input?.paymentCustomization?.metafield?.value ?? "{}" - ); - - return NO_CHANGES; -}; -{%- elsif flavor contains "typescript" -%} -import type { - RunInput, - FunctionRunResult, -} from "../generated/api"; - -const NO_CHANGES: FunctionRunResult = { - operations: [], -}; - -type Configuration = {}; - -export function run(input: RunInput): FunctionRunResult { - const configuration: Configuration = JSON.parse( - input?.paymentCustomization?.metafield?.value ?? "{}" - ); - return NO_CHANGES; -}; -{%- endif -%} diff --git a/checkout/rust/payment-customization/default/schema.graphql b/checkout/rust/payment-customization/default/schema.graphql index 306aa01b..298d9cd7 100644 --- a/checkout/rust/payment-customization/default/schema.graphql +++ b/checkout/rust/payment-customization/default/schema.graphql @@ -335,6 +335,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2791,6 +2802,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2800,7 +2850,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2810,7 +2860,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3785,7 +3835,7 @@ type Localization { """ 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.") } """ @@ -4053,7 +4103,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. @@ -4233,6 +4283,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4267,7 +4327,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4278,7 +4338,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4290,7 +4350,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4356,6 +4416,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ 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). diff --git a/checkout/rust/payment-customization/default/shopify.extension.toml.liquid b/checkout/rust/payment-customization/default/shopify.extension.toml.liquid index ca3558e6..9ff28a45 100644 --- a/checkout/rust/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/rust/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "src/run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "src/cart_payment_methods_transform_run.graphql" + export = "cart_payment_methods_transform_run" [extensions.build] command = "cargo build --target=wasm32-wasip1 --release" diff --git a/checkout/rust/payment-customization/default/src/run.graphql.liquid b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid similarity index 100% rename from checkout/rust/payment-customization/default/src/run.graphql.liquid rename to checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.graphql.liquid diff --git a/checkout/rust/payment-customization/default/src/run.rs b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs similarity index 64% rename from checkout/rust/payment-customization/default/src/run.rs rename to checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs index b8d88f47..341c0971 100644 --- a/checkout/rust/payment-customization/default/src/run.rs +++ b/checkout/rust/payment-customization/default/src/cart_payment_methods_transform_run.rs @@ -13,9 +13,9 @@ impl Configuration { } } -#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] -fn run(input: input::ResponseData) -> Result { - let no_changes = output::FunctionRunResult { operations: vec![] }; +#[shopify_function_target(query_path = "src/cart_payment_methods_transform_run.graphql", schema_path = "schema.graphql")] +fn cart_payment_methods_transform_run(input: input::ResponseData) -> Result { + let no_changes = output::CartPaymentMethodsTransformRunResult { operations: vec![] }; let _config = match input.payment_customization.metafield { Some(input::InputPaymentCustomizationMetafield { value }) => { @@ -24,7 +24,7 @@ fn run(input: input::ResponseData) -> Result { None => return Ok(no_changes), }; - Ok(output::FunctionRunResult { operations: vec![] }) + Ok(output::CartPaymentMethodsTransformRunResult { operations: vec![] }) } #[cfg(test)] @@ -34,10 +34,10 @@ mod tests { #[test] fn test_result_contains_no_operations() -> Result<()> { - use run::output::*; + use cart_payment_methods_transform_run::output::*; let result = run_function_with_input( - run, + cart_payment_methods_transform_run, r#" { "paymentCustomization": { @@ -46,7 +46,7 @@ mod tests { } "#, )?; - let expected = FunctionRunResult { operations: vec![] }; + let expected = CartPaymentMethodsTransformRunResult { operations: vec![] }; assert_eq!(result, expected); Ok(()) diff --git a/checkout/rust/payment-customization/default/src/main.rs b/checkout/rust/payment-customization/default/src/main.rs index 9272b027..fcdbf85e 100644 --- a/checkout/rust/payment-customization/default/src/main.rs +++ b/checkout/rust/payment-customization/default/src/main.rs @@ -1,5 +1,5 @@ use std::process; -pub mod run; +pub mod cart_payment_methods_transform_run; fn main() { eprintln!("Please invoke a named export."); diff --git a/checkout/wasm/payment-customization/default/run.graphql.liquid b/checkout/wasm/payment-customization/default/cart_payment_methods_transform_run.graphql.liquid similarity index 100% rename from checkout/wasm/payment-customization/default/run.graphql.liquid rename to checkout/wasm/payment-customization/default/cart_payment_methods_transform_run.graphql.liquid diff --git a/checkout/wasm/payment-customization/default/schema.graphql b/checkout/wasm/payment-customization/default/schema.graphql index 306aa01b..298d9cd7 100644 --- a/checkout/wasm/payment-customization/default/schema.graphql +++ b/checkout/wasm/payment-customization/default/schema.graphql @@ -335,6 +335,17 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +The `CartPaymentMethodsTransformRunResult` object is the output of the Function +run target. The object contains the operations to apply to payment methods in checkout. +""" +input CartPaymentMethodsTransformRunResult { + """ + The ordered list of operations to apply to the list of payment methods. + """ + operations: [Operation!]! +} + """ Whether the product is in the specified collection. @@ -2791,6 +2802,45 @@ enum DeliveryMethod { SHIPPING } +""" +An operation to apply to the list of payment methods. +""" +input DeprecatedOperation @oneOf { + """ + A request to hide a payment method during checkout. + + When your Function returns this operation, it removes the specified payment method + from the available options shown to customers during checkout. + + Use this operation when you want to conditionally hide payment methods based on + checkout attributes, customer data, or other business logic implemented in your Function. + """ + hide: HideOperation @deprecated(reason: "Use `paymentMethodHide` instead.") + + """ + A request to move a payment method to a new position in the checkout display order. + + When your Function returns this operation, it changes the display order of payment methods + by placing the specified payment method at the requested index position. + + Use this operation when you want to prioritize certain payment methods based on + checkout context, customer preferences, or other business logic implemented in your Function. + """ + move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + + """ + A request to change the displayed name of a payment method during checkout. + + When your Function returns this operation, it replaces the default name of the + specified payment method with the custom name that's provided in the request. + + Use this operation when you want to provide more context or clarity about + payment methods based on checkout details, locale, or other business logic + implemented in your Function. + """ + rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -2800,7 +2850,7 @@ input FunctionResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -2810,7 +2860,7 @@ input FunctionRunResult { """ The ordered list of operations to apply to the list of payment methods. """ - operations: [Operation!]! + operations: [DeprecatedOperation!]! } """ @@ -3785,7 +3835,7 @@ type Localization { """ 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.") } """ @@ -4053,7 +4103,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. @@ -4233,6 +4283,16 @@ input MoveOperation { The root mutation for the API. """ type MutationRoot { + """ + Handles the Function result for the cart.payment-methods.transform.run target. + """ + cartPaymentMethodsTransformRun( + """ + The result of the Function. + """ + result: CartPaymentMethodsTransformRunResult! + ): Void! + """ Handles the Function result. """ @@ -4267,7 +4327,7 @@ input Operation @oneOf { Use this operation when you want to conditionally hide payment methods based on checkout attributes, customer data, or other business logic implemented in your Function. """ - hide: HideOperation + paymentMethodHide: PaymentMethodHideOperation """ A request to move a payment method to a new position in the checkout display order. @@ -4278,7 +4338,7 @@ input Operation @oneOf { Use this operation when you want to prioritize certain payment methods based on checkout context, customer preferences, or other business logic implemented in your Function. """ - move: MoveOperation + paymentMethodMove: PaymentMethodMoveOperation """ A request to change the displayed name of a payment method during checkout. @@ -4290,7 +4350,7 @@ input Operation @oneOf { payment methods based on checkout details, locale, or other business logic implemented in your Function. """ - rename: RenameOperation + paymentMethodRename: PaymentMethodRenameOperation } """ @@ -4356,6 +4416,70 @@ enum PaymentCustomizationPaymentMethodPlacement { PAYMENT_METHOD } +""" +A request to hide a payment method during checkout. + +When your Function returns this operation, it removes the specified payment method +from the available options shown to customers during checkout. + +Use this operation when you want to conditionally hide payment methods based on +checkout attributes, customer data, or other business logic implemented in your Function. +""" +input PaymentMethodHideOperation { + """ + The identifier of the payment method to hide out. + """ + paymentMethodId: ID! + + """ + Placement types to hide. If not provided, all placements will be hidden. + """ + placements: [PaymentCustomizationPaymentMethodPlacement!] +} + +""" +A request to move a payment method to a new position in the checkout display order. + +When your Function returns this operation, it changes the display order of payment methods +by placing the specified payment method at the requested index position. + +Use this operation when you want to prioritize certain payment methods based on +checkout context, customer preferences, or other business logic implemented in your Function. +""" +input PaymentMethodMoveOperation { + """ + The index to move the payment method to. + """ + index: Int! + + """ + The identifier of the payment method to move. + """ + paymentMethodId: ID! +} + +""" +A request to change the displayed name of a payment method during checkout. + +When your Function returns this operation, it replaces the default name of the +specified payment method with the custom name that's provided in the request. + +Use this operation when you want to provide more context or clarity about +payment methods based on checkout details, locale, or other business logic +implemented in your Function. +""" +input PaymentMethodRenameOperation { + """ + The new name for the payment method. + """ + name: String! + + """ + The identifier of the payment method to rename. + """ + paymentMethodId: ID! +} + """ 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). diff --git a/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid b/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid index a97837c9..4125f154 100644 --- a/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid +++ b/checkout/wasm/payment-customization/default/shopify.extension.toml.liquid @@ -1,4 +1,4 @@ -api_version = "2025-01" +api_version = "2025-07" [[extensions]] name = "t:name" @@ -8,9 +8,9 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.payment-customization.run" - input_query = "run.graphql" - export = "run" + target = "cart.payment-methods.transform.run" + input_query = "cart_payment_methods_transform_run.graphql" + export = "cart_payment_methods_transform_run" [extensions.build] command = "echo 'build the wasm'" From f8e6ba0c120ab8b00bc478293963f3a665f764fd Mon Sep 17 00:00:00 2001 From: Martin Gingras Date: Wed, 7 May 2025 10:48:05 -0400 Subject: [PATCH 2/3] Update Validation function templates --- .../default/schema.graphql | 94 +++++++++++++- .../default/shopify.extension.toml.liquid | 9 +- ...t_validations_generate_run.graphql.liquid} | 2 +- .../src/cart_validations_generate_run.liquid | 56 +++++++++ .../cart_validations_generate_run.test.liquid | 119 ++++++++++++++++++ .../default/src/index.liquid | 2 +- .../default/src/run.liquid | 44 ------- .../default/src/run.test.liquid | 86 ------------- .../default/schema.graphql | 94 +++++++++++++- .../default/shopify.extension.toml.liquid | 9 +- ...t_validations_generate_run.graphql.liquid} | 0 ...un.rs => cart_validations_generate_run.rs} | 41 +++--- .../default/src/main.rs | 2 +- ...t_validations_generate_run.graphql.liquid} | 0 .../default/schema.graphql | 94 +++++++++++++- .../default/shopify.extension.toml.liquid | 9 +- 16 files changed, 480 insertions(+), 181 deletions(-) rename checkout/javascript/cart-checkout-validation/default/src/{run.graphql.liquid => cart_validations_generate_run.graphql.liquid} (54%) create mode 100644 checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.liquid create mode 100644 checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.test.liquid delete mode 100644 checkout/javascript/cart-checkout-validation/default/src/run.liquid delete mode 100644 checkout/javascript/cart-checkout-validation/default/src/run.test.liquid rename checkout/rust/cart-checkout-validation/default/src/{run.graphql.liquid => cart_validations_generate_run.graphql.liquid} (100%) rename checkout/rust/cart-checkout-validation/default/src/{run.rs => cart_validations_generate_run.rs} (53%) rename checkout/wasm/cart-checkout-validation/default/{run.graphql.liquid => cart_validations_generate_run.graphql.liquid} (100%) diff --git a/checkout/javascript/cart-checkout-validation/default/schema.graphql b/checkout/javascript/cart-checkout-validation/default/schema.graphql index 4173498a..29c32ced 100644 --- a/checkout/javascript/cart-checkout-validation/default/schema.graphql +++ b/checkout/javascript/cart-checkout-validation/default/schema.graphql @@ -13,6 +13,11 @@ 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 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. @@ -363,6 +368,27 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +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. @@ -3030,9 +3056,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. @@ -3099,7 +3125,7 @@ type Input { 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 regional and language settings that determine how the Function @@ -3973,7 +3999,7 @@ type Localization { """ 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.") } """ @@ -4241,7 +4267,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. @@ -4400,6 +4426,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. """ @@ -4431,6 +4477,16 @@ type MutationRoot { ): Void! } +""" +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). @@ -4820,6 +4876,32 @@ type Validation implements HasMetafields { ): 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..abbf39c4 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" - input_query = "src/run.graphql" - export = "run" + target = "cart.validations.generate.run" + input_query = "src/cart_validations_generate_run.graphql" + export = "cart-validations-generate-run" [extensions.build] command = "" path = "dist/function.wasm" - diff --git a/checkout/javascript/cart-checkout-validation/default/src/run.graphql.liquid b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.graphql.liquid similarity index 54% rename from checkout/javascript/cart-checkout-validation/default/src/run.graphql.liquid rename to checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.graphql.liquid index 82abd594..475dc446 100644 --- a/checkout/javascript/cart-checkout-validation/default/src/run.graphql.liquid +++ b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.graphql.liquid @@ -1,4 +1,4 @@ -query RunInput { +query CartValidationsGenerateRunInput { cart { lines { quantity diff --git a/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.liquid b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.liquid new file mode 100644 index 00000000..1cf13bd2 --- /dev/null +++ b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.liquid @@ -0,0 +1,56 @@ +{%- if flavor contains "vanilla-js" -%} +// @ts-check + +/** + * @typedef {import("../generated/api").CartValidationsGenerateRunInput} CartValidationsGenerateRunInput + * @typedef {import("../generated/api").CartValidationsGenerateRunResult} CartValidationsGenerateRunResult + */ + +/** + * @param {CartValidationsGenerateRunInput} input + * @returns {CartValidationsGenerateRunResult} + */ +export function cartValidationsGenerateRun(input) { + const errors = input.cart.lines + .filter(({ quantity }) => quantity > 1) + .map(() => ({ + message: "Not possible to order more than one of each", + target: "$.cart" + })); + + const operations = [ + { + validationAdd: { + errors + }, + }, + ]; + + return { operations }; +}; +{%- elsif flavor contains "typescript" -%} +import type { + CartValidationsGenerateRunInput, + CartValidationsGenerateRunResult, + ValidationError, +} from "../generated/api"; + +export function cartValidationsGenerateRun(input: CartValidationsGenerateRunInput): CartValidationsGenerateRunResult { + const errors: ValidationError[] = input.cart.lines + .filter(({ quantity }) => quantity > 1) + .map(() => ({ + message: "Not possible to order more than one of each", + target: "$.cart" + })); + + const operations = [ + { + validationAdd: { + errors + }, + }, + ]; + + return { operations }; +}; +{%- endif -%} diff --git a/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.test.liquid b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.test.liquid new file mode 100644 index 00000000..b343d706 --- /dev/null +++ b/checkout/javascript/cart-checkout-validation/default/src/cart_validations_generate_run.test.liquid @@ -0,0 +1,119 @@ +{%- if flavor contains "vanilla-js" -%} +import { describe, it, expect } from 'vitest'; +import { cartValidationsGenerateRun } from './cart_validations_generate_run'; + +/** + * @typedef {import("../generated/api").CartValidationsGenerateRunResult} CartValidationsGenerateRunResult + */ + +describe('cart checkout validation function', () => { + it('returns an error when quantity exceeds one', () => { + const result = cartValidationsGenerateRun({ + cart: { + lines: [ + { + quantity: 3 + } + ] + } + }); + const expected = /** @type {CartValidationsGenerateRunResult} */ ({ + operations: [ + { + validationAdd: { + errors: [ + { + message: "Not possible to order more than one of each", + target: "$.cart" + } + ] + } + } + ] + }); + + expect(result).toEqual(expected); + }); + + it('returns no errors when quantity is one', () => { + const result = cartValidationsGenerateRun({ + cart: { + lines: [ + { + quantity: 1 + } + ] + } + }); + const expected = /** @type {CartValidationsGenerateRunResult} */ ({ + operations: [ + { + validationAdd: { + errors: [] + } + } + ] + }); + + expect(result).toEqual(expected); + }); +}); + +{%- elsif flavor contains "typescript" -%} +import { describe, it, expect } from 'vitest'; +import { cartValidationsGenerateRun } from './cart_validations_generate_run'; +import { CartValidationsGenerateRunResult } from "../generated/api"; + +describe('cart checkout validation function', () => { + it('returns an error when quantity exceeds one', () => { + const result = cartValidationsGenerateRun({ + cart: { + lines: [ + { + quantity: 3 + } + ] + } + }); + const expected: CartValidationsGenerateRunResult = { + operations: [ + { + validationAdd: { + errors: [ + { + message: "Not possible to order more than one of each", + target: "$.cart" + } + ] + } + } + ] + }; + + expect(result).toEqual(expected); + }); + + it('returns no errors when quantity is one', () => { + const result = cartValidationsGenerateRun({ + cart: { + lines: [ + { + quantity: 1 + } + ] + } + }); + const expected: CartValidationsGenerateRunResult = { + operations: [ + { + validationAdd: { + errors: [] + } + } + ] + }; + + expect(result).toEqual(expected); + }); +}); +{%- endif -%} diff --git a/checkout/javascript/cart-checkout-validation/default/src/index.liquid b/checkout/javascript/cart-checkout-validation/default/src/index.liquid index 2e6f9676..77af359d 100644 --- a/checkout/javascript/cart-checkout-validation/default/src/index.liquid +++ b/checkout/javascript/cart-checkout-validation/default/src/index.liquid @@ -1 +1 @@ -export * from './run'; +export * from './cart_validations_generate_run'; diff --git a/checkout/javascript/cart-checkout-validation/default/src/run.liquid b/checkout/javascript/cart-checkout-validation/default/src/run.liquid deleted file mode 100644 index 4c76a0a9..00000000 --- a/checkout/javascript/cart-checkout-validation/default/src/run.liquid +++ /dev/null @@ -1,44 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -// @ts-check - -/** - * @typedef {import("../generated/api").RunInput} RunInput - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult - */ - -/** - * @param {RunInput} input - * @returns {FunctionRunResult} - */ -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", - })); - - return { - errors - } -}; -{%- elsif flavor contains "typescript" -%} -import type { - RunInput, - FunctionRunResult, - FunctionError, -} from "../generated/api"; - -export function run(input: RunInput): FunctionRunResult { - const errors: FunctionError[] = input.cart.lines - .filter(({ quantity }) => quantity > 1) - .map(() => ({ - localizedMessage: "Not possible to order more than one of each", - target: "$.cart", - })); - - return { - errors - } -}; -{%- 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 deleted file mode 100644 index 47eefa63..00000000 --- a/checkout/javascript/cart-checkout-validation/default/src/run.test.liquid +++ /dev/null @@ -1,86 +0,0 @@ -{%- if flavor contains "vanilla-js" -%} -import { describe, it, expect } from 'vitest'; -import { run } from './run'; - -/** - * @typedef {import("../generated/api").FunctionRunResult} FunctionRunResult - */ - -describe('cart checkout validation function', () => { - it('returns an error when quantity exceeds one', () => { - const result = run({ - cart: { - lines: [ - { - quantity: 3 - } - ] - } - }); - const expected = /** @type {FunctionRunResult} */ ({ errors: [ - { - localizedMessage: "Not possible to order more than one of each", - target: "$.cart" - } - ] }); - - expect(result).toEqual(expected); - }); - - it('returns no errors when quantity is one', () => { - const result = run({ - cart: { - lines: [ - { - quantity: 1 - } - ] - } - }); - const expected = /** @type {FunctionRunResult} */ ({ errors: [] }); - - expect(result).toEqual(expected); - }); -}); -{%- elsif flavor contains "typescript" -%} -import { describe, it, expect } from 'vitest'; -import { run } from './run'; -import { FunctionRunResult } from "../generated/api"; - -describe('cart checkout validation function', () => { - it('returns an error when quantity exceeds one', () => { - const result = run({ - cart: { - lines: [ - { - quantity: 3 - } - ] - } - }); - const expected: FunctionRunResult = { errors: [ - { - localizedMessage: "Not possible to order more than one of each", - target: "$.cart" - } - ] }; - - expect(result).toEqual(expected); - }); - - it('returns no errors when quantity is one', () => { - const result = run({ - cart: { - lines: [ - { - quantity: 1 - } - ] - } - }); - const expected: FunctionRunResult = { errors: [] }; - - expect(result).toEqual(expected); - }); -}); -{%- endif -%} diff --git a/checkout/rust/cart-checkout-validation/default/schema.graphql b/checkout/rust/cart-checkout-validation/default/schema.graphql index 4173498a..29c32ced 100644 --- a/checkout/rust/cart-checkout-validation/default/schema.graphql +++ b/checkout/rust/cart-checkout-validation/default/schema.graphql @@ -13,6 +13,11 @@ 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 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. @@ -363,6 +368,27 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +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. @@ -3030,9 +3056,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. @@ -3099,7 +3125,7 @@ type Input { 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 regional and language settings that determine how the Function @@ -3973,7 +3999,7 @@ type Localization { """ 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.") } """ @@ -4241,7 +4267,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. @@ -4400,6 +4426,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. """ @@ -4431,6 +4477,16 @@ type MutationRoot { ): Void! } +""" +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). @@ -4820,6 +4876,32 @@ type Validation implements HasMetafields { ): 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..3ac49d65 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,12 +8,11 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.validation.run" - input_query = "src/run.graphql" - export = "run" + target = "cart.validations.generate.run" + input_query = "src/cart_validations_generate_run.graphql" + export = "cart_validations_generate_run" [extensions.build] 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.graphql.liquid b/checkout/rust/cart-checkout-validation/default/src/cart_validations_generate_run.graphql.liquid similarity index 100% rename from checkout/rust/cart-checkout-validation/default/src/run.graphql.liquid rename to checkout/rust/cart-checkout-validation/default/src/cart_validations_generate_run.graphql.liquid diff --git a/checkout/rust/cart-checkout-validation/default/src/run.rs b/checkout/rust/cart-checkout-validation/default/src/cart_validations_generate_run.rs similarity index 53% rename from checkout/rust/cart-checkout-validation/default/src/run.rs rename to checkout/rust/cart-checkout-validation/default/src/cart_validations_generate_run.rs index ca0fef5d..3d7fb727 100644 --- a/checkout/rust/cart-checkout-validation/default/src/run.rs +++ b/checkout/rust/cart-checkout-validation/default/src/cart_validations_generate_run.rs @@ -6,8 +6,9 @@ use serde::{Deserialize, Serialize}; #[derive(Serialize, Deserialize, Default, PartialEq)] struct Config {} -#[shopify_function_target(query_path = "src/run.graphql", schema_path = "schema.graphql")] -fn run(input: input::ResponseData) -> Result { +#[shopify_function_target(query_path = "src/cart_validations_generate_run.graphql", schema_path = "schema.graphql")] +fn cart_validations_generate_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)] @@ -32,10 +37,10 @@ mod tests { #[test] fn test_result_contains_single_error_when_quantity_exceeds_one() -> Result<()> { - use run::output::*; + use cart_validations_generate_run::output::*; let result = run_function_with_input( - run, + cart_validations_generate_run, r#" { "cart": { @@ -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); @@ -61,10 +68,10 @@ mod tests { #[test] fn test_result_contains_no_errors_when_quantity_is_one() -> Result<()> { - use run::output::*; + use cart_validations_generate_run::output::*; let result = run_function_with_input( - run, + cart_validations_generate_run, r#" { "cart": { @@ -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/rust/cart-checkout-validation/default/src/main.rs b/checkout/rust/cart-checkout-validation/default/src/main.rs index 9272b027..a52c24dc 100644 --- a/checkout/rust/cart-checkout-validation/default/src/main.rs +++ b/checkout/rust/cart-checkout-validation/default/src/main.rs @@ -1,5 +1,5 @@ use std::process; -pub mod run; +pub mod cart_validations_generate_run; fn main() { eprintln!("Please invoke a named export."); diff --git a/checkout/wasm/cart-checkout-validation/default/run.graphql.liquid b/checkout/wasm/cart-checkout-validation/default/cart_validations_generate_run.graphql.liquid similarity index 100% rename from checkout/wasm/cart-checkout-validation/default/run.graphql.liquid rename to checkout/wasm/cart-checkout-validation/default/cart_validations_generate_run.graphql.liquid diff --git a/checkout/wasm/cart-checkout-validation/default/schema.graphql b/checkout/wasm/cart-checkout-validation/default/schema.graphql index 4173498a..29c32ced 100644 --- a/checkout/wasm/cart-checkout-validation/default/schema.graphql +++ b/checkout/wasm/cart-checkout-validation/default/schema.graphql @@ -13,6 +13,11 @@ 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 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. @@ -363,6 +368,27 @@ type CartLineCost { totalAmount: MoneyV2! } +""" +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. @@ -3030,9 +3056,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. @@ -3099,7 +3125,7 @@ type Input { 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 regional and language settings that determine how the Function @@ -3973,7 +3999,7 @@ type Localization { """ 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.") } """ @@ -4241,7 +4267,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. @@ -4400,6 +4426,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. """ @@ -4431,6 +4477,16 @@ type MutationRoot { ): Void! } +""" +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). @@ -4820,6 +4876,32 @@ type Validation implements HasMetafields { ): 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..2ec3c11a 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,12 +8,11 @@ type = "function" description = "t:description" [[extensions.targeting]] - target = "purchase.validation.run" - input_query = "run.graphql" - export = "run" + target = "cart.validations.generate.run" + input_query = "cart_validations_generate_run.graphql" + export = "cart_validations_generate_run" [extensions.build] command = "echo 'build the wasm'" path = "" watch = [] - From fd2c6d55032a46d4517ea627c5853fec9a132312 Mon Sep 17 00:00:00 2001 From: Thierry Joyal Date: Thu, 26 Jun 2025 16:51:20 -0400 Subject: [PATCH 3/3] Update schemas --- .../default/schema.graphql | 190 +++++++++++- .../default/schema.graphql | 287 +++++++++++++++++- .../default/schema.graphql | 190 +++++++++++- .../default/schema.graphql | 287 +++++++++++++++++- .../default/schema.graphql | 190 +++++++++++- .../default/schema.graphql | 287 +++++++++++++++++- 6 files changed, 1395 insertions(+), 36 deletions(-) diff --git a/checkout/javascript/cart-checkout-validation/default/schema.graphql b/checkout/javascript/cart-checkout-validation/default/schema.graphql index 29c32ced..27fd90e2 100644 --- a/checkout/javascript/cart-checkout-validation/default/schema.graphql +++ b/checkout/javascript/cart-checkout-validation/default/schema.graphql @@ -109,7 +109,7 @@ enum BuyerJourneyStep { 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 { +type Cart implements HasMetafields { """ 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, @@ -173,6 +173,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -226,6 +254,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -238,6 +271,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -384,7 +433,8 @@ that display to customers and prevent them from proceeding through checkout. """ input CartValidationsGenerateRunResult { """ - The ordered list of operations to apply. + An ordered list of operations to be executed for the validations associated with the + cart and checkout processes. """ operations: [Operation!]! } @@ -3056,9 +3106,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. @@ -4215,6 +4265,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4482,7 +4645,8 @@ An operation to apply. """ input Operation @oneOf { """ - Add a performed validation. + An operation that adds validations to the cart and checkout. For example, you might add a validation + that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ validationAdd: ValidationAddOperation } @@ -4877,11 +5041,14 @@ type Validation implements HasMetafields { } """ -Add a performed validation. +An operation that adds validations to the cart and checkout. For example, you might add a validation +that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ input ValidationAddOperation { """ - Errors. + The validation errors that block a customer from proceeding through checkout. + The errors are grouped by + [target](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets). """ errors: [ValidationError!]! } @@ -4891,13 +5058,14 @@ A Function error for a path. """ input ValidationError { """ - Returns a message describing the error. + A description of the validation error. For example, "The product is out of stock" or + "The product isn't available for purchase in your region". """ 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. + The [identifier](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + in `shopify.extension.toml` that specifies where you're injecting code in the checkout process. """ target: String! } diff --git a/checkout/javascript/payment-customization/default/schema.graphql b/checkout/javascript/payment-customization/default/schema.graphql index 298d9cd7..e936b0b6 100644 --- a/checkout/javascript/payment-customization/default/schema.graphql +++ b/checkout/javascript/payment-customization/default/schema.graphql @@ -76,7 +76,7 @@ type BuyerIdentity { 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 { +type Cart implements HasMetafields { """ 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, @@ -140,6 +140,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -193,6 +221,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -205,6 +238,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -2802,6 +2851,16 @@ enum DeliveryMethod { SHIPPING } +""" +The percentage deposit required at checkout for the order. +""" +input Deposit { + """ + The percentage of the order total that should be paid as a deposit. Must be between 1 and 99, inclusive. + """ + percentage: Float! +} + """ An operation to apply to the list of payment methods. """ @@ -2828,6 +2887,11 @@ input DeprecatedOperation @oneOf { """ move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation + """ A request to change the displayed name of a payment method during checkout. @@ -2841,6 +2905,36 @@ input DeprecatedOperation @oneOf { rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") } +""" +The input to set event-based payment terms. +""" +input EventPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The event that triggers the payment terms. + """ + trigger: PaymentTermsTriggerEvent! +} + +""" +The input to set fixed payment terms. +""" +input FixedPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The due date for fixed payment terms. + """ + dueAt: DateTime! +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -4051,6 +4145,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4314,6 +4521,29 @@ type MutationRoot { ): Void! } +""" +The input to set net payment terms. +""" +input NetPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The number of days until the payment is due. + Currently supported values are restricted to 7, 15, 30, 45, 60, and 90. + These values may change in the future as restrictions are lifted, + but existing values will continue to be supported. + """ + dueInDays: Int! + + """ + The issued date of net payment terms. Set to current time if nil. + """ + issuedAt: DateTime +} + """ An operation to apply to the list of payment methods. """ @@ -4351,6 +4581,11 @@ input Operation @oneOf { implemented in your Function. """ paymentMethodRename: PaymentMethodRenameOperation + + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation } """ @@ -4480,6 +4715,56 @@ input PaymentMethodRenameOperation { paymentMethodId: ID! } +""" +The payment terms to set. +""" +input PaymentTerms @oneOf { + """ + The input to set event-based payment terms. + """ + event: EventPaymentTerms + + """ + The input to set fixed payment terms. + """ + fixed: FixedPaymentTerms + + """ + The input to set net payment terms. + """ + net: NetPaymentTerms +} + +""" +Request to set the payment terms. +""" +input PaymentTermsSetOperation { + """ + The payment terms to set. No payment terms when nil + """ + paymentTerms: PaymentTerms +} + +""" +The event that triggers the payment terms. +""" +enum PaymentTermsTriggerEvent { + """ + Triggered when a fulfillment is created. + """ + FULFILLMENT_CREATED + + """ + Triggered when an invoice is sent. + """ + INVOICE_SENT + + """ + Triggered when an order is fulfilled. + """ + ORDER_FULFILLED +} + """ 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). diff --git a/checkout/rust/cart-checkout-validation/default/schema.graphql b/checkout/rust/cart-checkout-validation/default/schema.graphql index 29c32ced..27fd90e2 100644 --- a/checkout/rust/cart-checkout-validation/default/schema.graphql +++ b/checkout/rust/cart-checkout-validation/default/schema.graphql @@ -109,7 +109,7 @@ enum BuyerJourneyStep { 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 { +type Cart implements HasMetafields { """ 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, @@ -173,6 +173,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -226,6 +254,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -238,6 +271,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -384,7 +433,8 @@ that display to customers and prevent them from proceeding through checkout. """ input CartValidationsGenerateRunResult { """ - The ordered list of operations to apply. + An ordered list of operations to be executed for the validations associated with the + cart and checkout processes. """ operations: [Operation!]! } @@ -3056,9 +3106,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. @@ -4215,6 +4265,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4482,7 +4645,8 @@ An operation to apply. """ input Operation @oneOf { """ - Add a performed validation. + An operation that adds validations to the cart and checkout. For example, you might add a validation + that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ validationAdd: ValidationAddOperation } @@ -4877,11 +5041,14 @@ type Validation implements HasMetafields { } """ -Add a performed validation. +An operation that adds validations to the cart and checkout. For example, you might add a validation +that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ input ValidationAddOperation { """ - Errors. + The validation errors that block a customer from proceeding through checkout. + The errors are grouped by + [target](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets). """ errors: [ValidationError!]! } @@ -4891,13 +5058,14 @@ A Function error for a path. """ input ValidationError { """ - Returns a message describing the error. + A description of the validation error. For example, "The product is out of stock" or + "The product isn't available for purchase in your region". """ 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. + The [identifier](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + in `shopify.extension.toml` that specifies where you're injecting code in the checkout process. """ target: String! } diff --git a/checkout/rust/payment-customization/default/schema.graphql b/checkout/rust/payment-customization/default/schema.graphql index 298d9cd7..e936b0b6 100644 --- a/checkout/rust/payment-customization/default/schema.graphql +++ b/checkout/rust/payment-customization/default/schema.graphql @@ -76,7 +76,7 @@ type BuyerIdentity { 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 { +type Cart implements HasMetafields { """ 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, @@ -140,6 +140,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -193,6 +221,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -205,6 +238,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -2802,6 +2851,16 @@ enum DeliveryMethod { SHIPPING } +""" +The percentage deposit required at checkout for the order. +""" +input Deposit { + """ + The percentage of the order total that should be paid as a deposit. Must be between 1 and 99, inclusive. + """ + percentage: Float! +} + """ An operation to apply to the list of payment methods. """ @@ -2828,6 +2887,11 @@ input DeprecatedOperation @oneOf { """ move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation + """ A request to change the displayed name of a payment method during checkout. @@ -2841,6 +2905,36 @@ input DeprecatedOperation @oneOf { rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") } +""" +The input to set event-based payment terms. +""" +input EventPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The event that triggers the payment terms. + """ + trigger: PaymentTermsTriggerEvent! +} + +""" +The input to set fixed payment terms. +""" +input FixedPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The due date for fixed payment terms. + """ + dueAt: DateTime! +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -4051,6 +4145,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4314,6 +4521,29 @@ type MutationRoot { ): Void! } +""" +The input to set net payment terms. +""" +input NetPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The number of days until the payment is due. + Currently supported values are restricted to 7, 15, 30, 45, 60, and 90. + These values may change in the future as restrictions are lifted, + but existing values will continue to be supported. + """ + dueInDays: Int! + + """ + The issued date of net payment terms. Set to current time if nil. + """ + issuedAt: DateTime +} + """ An operation to apply to the list of payment methods. """ @@ -4351,6 +4581,11 @@ input Operation @oneOf { implemented in your Function. """ paymentMethodRename: PaymentMethodRenameOperation + + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation } """ @@ -4480,6 +4715,56 @@ input PaymentMethodRenameOperation { paymentMethodId: ID! } +""" +The payment terms to set. +""" +input PaymentTerms @oneOf { + """ + The input to set event-based payment terms. + """ + event: EventPaymentTerms + + """ + The input to set fixed payment terms. + """ + fixed: FixedPaymentTerms + + """ + The input to set net payment terms. + """ + net: NetPaymentTerms +} + +""" +Request to set the payment terms. +""" +input PaymentTermsSetOperation { + """ + The payment terms to set. No payment terms when nil + """ + paymentTerms: PaymentTerms +} + +""" +The event that triggers the payment terms. +""" +enum PaymentTermsTriggerEvent { + """ + Triggered when a fulfillment is created. + """ + FULFILLMENT_CREATED + + """ + Triggered when an invoice is sent. + """ + INVOICE_SENT + + """ + Triggered when an order is fulfilled. + """ + ORDER_FULFILLED +} + """ 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). diff --git a/checkout/wasm/cart-checkout-validation/default/schema.graphql b/checkout/wasm/cart-checkout-validation/default/schema.graphql index 29c32ced..27fd90e2 100644 --- a/checkout/wasm/cart-checkout-validation/default/schema.graphql +++ b/checkout/wasm/cart-checkout-validation/default/schema.graphql @@ -109,7 +109,7 @@ enum BuyerJourneyStep { 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 { +type Cart implements HasMetafields { """ 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, @@ -173,6 +173,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -226,6 +254,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -238,6 +271,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -384,7 +433,8 @@ that display to customers and prevent them from proceeding through checkout. """ input CartValidationsGenerateRunResult { """ - The ordered list of operations to apply. + An ordered list of operations to be executed for the validations associated with the + cart and checkout processes. """ operations: [Operation!]! } @@ -3056,9 +3106,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. @@ -4215,6 +4265,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4482,7 +4645,8 @@ An operation to apply. """ input Operation @oneOf { """ - Add a performed validation. + An operation that adds validations to the cart and checkout. For example, you might add a validation + that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ validationAdd: ValidationAddOperation } @@ -4877,11 +5041,14 @@ type Validation implements HasMetafields { } """ -Add a performed validation. +An operation that adds validations to the cart and checkout. For example, you might add a validation +that, at checkout, confirms a customer's age meets the legal requirement to purchase a product in their cart. """ input ValidationAddOperation { """ - Errors. + The validation errors that block a customer from proceeding through checkout. + The errors are grouped by + [target](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets). """ errors: [ValidationError!]! } @@ -4891,13 +5058,14 @@ A Function error for a path. """ input ValidationError { """ - Returns a message describing the error. + A description of the validation error. For example, "The product is out of stock" or + "The product isn't available for purchase in your region". """ 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. + The [identifier](https://shopify.dev/docs/api/functions/reference/cart-checkout-validation/graphql#supported-checkout-field-targets) + in `shopify.extension.toml` that specifies where you're injecting code in the checkout process. """ target: String! } diff --git a/checkout/wasm/payment-customization/default/schema.graphql b/checkout/wasm/payment-customization/default/schema.graphql index 298d9cd7..e936b0b6 100644 --- a/checkout/wasm/payment-customization/default/schema.graphql +++ b/checkout/wasm/payment-customization/default/schema.graphql @@ -76,7 +76,7 @@ type BuyerIdentity { 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 { +type Cart implements HasMetafields { """ 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, @@ -140,6 +140,34 @@ type Cart { """ keys: [LocalizedFieldKey!]! = [] ): [LocalizedField!]! + + """ + 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 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! + + """ + 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 physical location where a retail order is created or completed. + """ + retailLocation: Location } """ @@ -193,6 +221,11 @@ type CartDeliveryGroup { """ deliveryOptions: [CartDeliveryOption!]! + """ + The type of merchandise in the delivery group. + """ + groupType: CartDeliveryGroupType! + """ A [globally-unique ID](https://shopify.dev/docs/api/usage/gids) for the delivery group. @@ -205,6 +238,22 @@ type CartDeliveryGroup { selectedDeliveryOption: CartDeliveryOption } +""" +Defines what type of merchandise is in the delivery group. +""" +enum CartDeliveryGroupType { + """ + The delivery group only contains merchandise that is either a one time purchase or a first delivery of + subscription merchandise. + """ + ONE_TIME_PURCHASE + + """ + The delivery group only contains subscription merchandise. + """ + SUBSCRIPTION +} + """ 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 @@ -2802,6 +2851,16 @@ enum DeliveryMethod { SHIPPING } +""" +The percentage deposit required at checkout for the order. +""" +input Deposit { + """ + The percentage of the order total that should be paid as a deposit. Must be between 1 and 99, inclusive. + """ + percentage: Float! +} + """ An operation to apply to the list of payment methods. """ @@ -2828,6 +2887,11 @@ input DeprecatedOperation @oneOf { """ move: MoveOperation @deprecated(reason: "Use `paymentMethodMove` instead.") + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation + """ A request to change the displayed name of a payment method during checkout. @@ -2841,6 +2905,36 @@ input DeprecatedOperation @oneOf { rename: RenameOperation @deprecated(reason: "Use `paymentMethodRename` instead.") } +""" +The input to set event-based payment terms. +""" +input EventPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The event that triggers the payment terms. + """ + trigger: PaymentTermsTriggerEvent! +} + +""" +The input to set fixed payment terms. +""" +input FixedPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The due date for fixed payment terms. + """ + dueAt: DateTime! +} + """ The output of the Function run target. The object contains the operations to apply to payment methods in checkout. In API versions 2023-10 and beyond, this @@ -4051,6 +4145,119 @@ enum LocalizedFieldKey { TAX_EMAIL_IT } +""" +Represents the location where the inventory resides. +""" +type Location implements HasMetafields { + """ + The address of this location. + """ + address: LocationAddress! + + """ + The location handle. + """ + handle: Handle! + + """ + The location id. + """ + id: ID! + + """ + 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 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! + + """ + 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 name of the location. + """ + name: String! +} + +""" +Represents the address of a location. +""" +type LocationAddress { + """ + The first line of the address for the location. + """ + address1: String + + """ + The second line of the address for the location. + """ + address2: String + + """ + The city of the location. + """ + city: String + + """ + The country of the location. + """ + country: String + + """ + The country code of the location. + """ + countryCode: String + + """ + A formatted version of the address for the location. + """ + formatted: [String!]! + + """ + The approximate latitude coordinates of the location. + """ + latitude: Float + + """ + The approximate longitude coordinates of the location. + """ + longitude: Float + + """ + The phone number of the location. + """ + phone: String + + """ + The province of the location. + """ + province: String + + """ + The code for the province, state, or district of the address of the location. + """ + provinceCode: String + + """ + The ZIP code of the location. + """ + zip: String +} + """ Represents a mailing address. """ @@ -4314,6 +4521,29 @@ type MutationRoot { ): Void! } +""" +The input to set net payment terms. +""" +input NetPaymentTerms { + """ + The deposit for payment terms. No deposit by default. + """ + deposit: Deposit + + """ + The number of days until the payment is due. + Currently supported values are restricted to 7, 15, 30, 45, 60, and 90. + These values may change in the future as restrictions are lifted, + but existing values will continue to be supported. + """ + dueInDays: Int! + + """ + The issued date of net payment terms. Set to current time if nil. + """ + issuedAt: DateTime +} + """ An operation to apply to the list of payment methods. """ @@ -4351,6 +4581,11 @@ input Operation @oneOf { implemented in your Function. """ paymentMethodRename: PaymentMethodRenameOperation + + """ + Request to set the payment terms. + """ + paymentTermsSet: PaymentTermsSetOperation } """ @@ -4480,6 +4715,56 @@ input PaymentMethodRenameOperation { paymentMethodId: ID! } +""" +The payment terms to set. +""" +input PaymentTerms @oneOf { + """ + The input to set event-based payment terms. + """ + event: EventPaymentTerms + + """ + The input to set fixed payment terms. + """ + fixed: FixedPaymentTerms + + """ + The input to set net payment terms. + """ + net: NetPaymentTerms +} + +""" +Request to set the payment terms. +""" +input PaymentTermsSetOperation { + """ + The payment terms to set. No payment terms when nil + """ + paymentTerms: PaymentTerms +} + +""" +The event that triggers the payment terms. +""" +enum PaymentTermsTriggerEvent { + """ + Triggered when a fulfillment is created. + """ + FULFILLMENT_CREATED + + """ + Triggered when an invoice is sent. + """ + INVOICE_SENT + + """ + Triggered when an order is fulfilled. + """ + ORDER_FULFILLED +} + """ 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).