Presents the Shopify checkout sheet for the given checkout URL.
Opens a native checkout sheet that handles the entire purchase flow, including payment processing, shipping selection, and order confirmation.
Important:
shopify.checkout.alreadyInProgressshopify.checkout.abandonedshopify.checkout.failedExample:
const modules = await Eitri.modules()
const shopifyStartCheckout = modules.shopify?.startCheckout
if (!shopifyStartCheckout) return
try {
const result = await shopifyStartCheckout({
checkoutUrl: "https://your-store.myshopify.com/checkouts/cn/Z2NwLXVzLWVh...",
colorScheme: "automatic" // optional: "automatic" | "light" | "dark"
})
// Access the order ID
console.log("Order completed! Order ID:", result.orderDetails.id)
// Access customer information
console.log("Customer email:", result.orderDetails.email)
// Access cart details
const { cart } = result.orderDetails
console.log("Total:", cart.price.total?.amount, cart.price.total?.currencyCode)
// Access line items
cart.lines.forEach(line => {
console.log(`${line.title} x ${line.quantity}`)
})
// Navigate to order confirmation screen
} catch (error) {
if (error.message?.includes("abandoned")) {
console.log("User cancelled checkout")
} else {
console.error("Checkout failed:", error)
}
}
Object containing the checkoutUrl to present
Promise resolving to ShopifyCheckoutResult with full order details
Preloads a Shopify checkout URL for faster presentation.
Call this method when you anticipate the user will proceed to checkout soon
(e.g., when viewing the cart). The checkout sheet will load in the background,
resulting in a faster presentation when startCheckout is called.
Best Practices:
Example:
const modules = await Eitri.modules()
const shopifyPreload = modules.shopify?.preload
if (!shopifyPreload) return
// Preload when user views cart
shopifyPreload({
checkoutUrl: "https://your-store.myshopify.com/checkouts/cn/Z2NwLXVzLWVh..."
})
Object containing the checkoutUrl to preload
Invalidates any preloaded checkout data.
Call this method when the preloaded checkout is no longer valid, such as when the cart contents change significantly or when the user logs out.
When to call:
Example:
const modules = await Eitri.modules()
const shopifyInvalidate = modules.shopify?.invalidate
if (!shopifyInvalidate) return
// Invalidate when cart is cleared
async function clearCart() {
await cartService.clear()
shopifyInvalidate()
}
Functions that allow an Eitri-App to integrate with Shopify Checkout.
Shopify Checkout provides a native, optimized checkout experience using Shopify's Checkout Sheet Kit. This allows customers to complete their purchase without leaving the app, providing a seamless and secure checkout flow.
Important Notes:
preloadto improve checkout presentation speed