Open Checkout
opens Shopify checkout inside the app
Description
The openCheckout action navigates the user directly to the Shopify checkout page inside the Superfans app.
It allows customers to review their cart items, apply discounts, and complete their purchase — all within the in-app experience.
Function Signature
VajroSDK.actions.openCheckout()| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Checkout page opened successfully" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
document.getElementById('promoBanner').addEventListener('click', () => {
VajroSDK.actions.addToCart([
{
variantId: "45253067702457", // Example variant ID
quantity: 1
}
]).then(() => {
VajroSDK.actions.openCheckout();
});
});.promo-banner {
background-color: #ffcc00;
color: #333;
padding: 20px;
text-align: center;
border-radius: 8px;
cursor: pointer;
transition: background-color 0.3s;
}
.promo-banner:hover {
background-color: #e6b800;
}<div class="promo-banner" id="promoBanner">
<h3>Exclusive Offer!</h3>
<p>Click here to checkout with our special deal.</p>
</div>Best Practices
- Trigger only with items in cart: Always verify the cart isn’t empty before opening checkout.
- Combine with validation: Ensure customer details and discount codes are applied first.
- Pair with enableCheckoutButton / disableCheckoutButton: Use these to manage checkout access state.
- Handle asynchronous flow: Await the Promise to control subsequent UI updates.
Caveats
- Active cart required: The user must have at least one product in their cart for checkout to initialize.
- App-only navigation: Checkout opens within the Superfans app, not in an external browser.
- No post-checkout event: The SDK doesn’t emit an event when checkout completes or closes.
- Payment handling: Checkout uses Shopify’s native payment flow — not customizable via SDK.
- Asynchronous behavior: Always handle errors or user interruptions gracefully.
Updated about 1 month ago