Cart and Checkout Validation API reference
The Validation API enables you to provide your own validation of a cart and checkout.
Extension targets
Anchor link to section titled "Extension targets"The Validation API exposes the following targets:
Target | Output type | Description |
---|---|---|
purchase.validation.fetch |
FunctionFetchResult | See Network access for Shopify Function |
purchase.validation.run |
FunctionRunResult | Outputs the list of validation errors |
The RunInput
object is the complete schema that your function can receive as input.
For a list of fields that the Validation API's Input
object accepts, refer to Input.
The following example shows an input query:
The following example shows the resulting input to the query:
FunctionRunResult
Anchor link to section titled "FunctionRunResult"The FunctionRunResult
object is the expected output for the purchase.validation.run
target.
The following function result shows errors that block a customer from proceeding through checkout.
Supported checkout field targets
Anchor link to section titled "Supported checkout field targets"The following checkout UI fields can be targeted with an error message. The target
property follows the input query's data structure.
Field | Target value | |
---|---|---|
cart |
$.cart | |
email |
$.cart.buyerIdentity.email | |
phone |
$.cart.buyerIdentity.phone | |
address1 |
$.cart.deliveryGroups[0].deliveryAddress.address1 | |
address2 |
$.cart.deliveryGroups[0].deliveryAddress.address2 | |
city |
$.cart.deliveryGroups[0].deliveryAddress.city | |
company |
$.cart.deliveryGroups[0].deliveryAddress.company | |
countryCode |
$.cart.deliveryGroups[0].deliveryAddress.countryCode | |
firstName |
$.cart.deliveryGroups[0].deliveryAddress.firstName | |
lastName |
$.cart.deliveryGroups[0].deliveryAddress.lastName | |
phone |
$.cart.deliveryGroups[0].deliveryAddress.phone | |
provinceCode |
$.cart.deliveryGroups[0].deliveryAddress.provinceCode | |
zip |
$.cart.deliveryGroups[0].deliveryAddress.zip |