Open Cart
Opens cart page of the app
Description
The openCart action navigates the user directly to the active cart page within the app.
It provides a seamless way to programmatically take the user to their current cart, allowing them to review items, apply discounts, or proceed to checkout — all without reloading or external links.
Function Signature
VajroSDK.actions.openCart() | Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Cart opened successfully" } |
| Cart not accessible | { "status": "error", "errorId": 400, "errorHandle": "cart-not-accessible", "message": "Cart not accessible at the moment, please try again" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
document.getElementById('openCartButton').addEventListener('click', () => {
VajroSDK.actions.openCart();
});<div class="cart-container">
<button class="open-cart-btn" id="openCartButton">Go to Cart</button>
</div>.cart-container {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background-color: #f0f0f0;
}
.open-cart-btn {
background-color: #28a745;
color: #fff;
border: none;
padding: 15px 30px;
border-radius: 8px;
font-size: 16px;
cursor: pointer;
transition: background-color 0.3s;
}
.open-cart-btn:hover {
background-color: #218838;
}Best Practices
- Use after Add to Cart: Combine with the addToCart action to automatically open the cart after a product is added.
- Avoid duplicate triggers: Debounce button clicks to prevent multiple cart openings.
- Pair with cartUpdated: Listen to cart changes to show dynamic totals or feedback before navigation.
- UI placement: Use for cart icons or success toasts (“View Cart” CTA).
Caveats
- In-app only: This action only works inside the Superfans mobile app — it won’t open the Shopify web cart.
- Cart dependency: The user must have an initialized cart session; otherwise, an empty cart view is shown.
- No return event: Once on the cart page, this action does not emit a callback or listener.
- Async behavior: Always handle the returned Promise to prevent unhandled exceptions.
Updated about 1 month ago