useCheckoutSession
hook provides access to the current checkout session data and functionality to update it. It gives you access to both the parsed, platform-agnostic checkout session data and the raw session data from the e-commerce platform.
session: CheckoutSession<Extensions>
- The parsed, platform-agnostic checkout session conforming to your custom schemarawSession: unknown
- The original session data from the e-commerce platform (VTEX, Shopify, etc.) in raw/unparsed formupdateSession: (session: CheckoutSession<Extensions>, rawSession: unknown) => void
- Function to update both the parsed and raw session datasessionValidity?: ValidationSuccess | ValidationFailure
- Results from the last validation check of the session datasessionValidity
object contains the results of validating the checkout session against a ZodSchema. This schema-based validation ensures that all required data is present and formatted correctly.
sessionValidity
uses a ZodSchema to validate the structure and content of your checkout sessionuseCheckoutSession<YourExtensions>()
when you have custom properties in your checkout session