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() 
ParameterTypeRequiredDescription
NilNilNilThis action does not require any parameter.

Structure of Response

StatusResponse
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

  1. Use after Add to Cart: Combine with the addToCart action to automatically open the cart after a product is added.
  2. Avoid duplicate triggers: Debounce button clicks to prevent multiple cart openings.
  3. Pair with cartUpdated: Listen to cart changes to show dynamic totals or feedback before navigation.
  4. UI placement: Use for cart icons or success toasts (“View Cart” CTA).

Caveats

  1. In-app only: This action only works inside the Superfans mobile app — it won’t open the Shopify web cart.
  2. Cart dependency: The user must have an initialized cart session; otherwise, an empty cart view is shown.
  3. No return event: Once on the cart page, this action does not emit a callback or listener.
  4. Async behavior: Always handle the returned Promise to prevent unhandled exceptions.