Refresh Cart
Reloads the latest cart from the app.
Description
The refreshCart() action reloads the latest cart from the native app.
Use it after cart properties change, or whenever custom block UI needs to re-read Superfans.variables.cart.
Function Signature
await Superfans.actions.refreshCart();| Parameter | Type | Required | Description |
|---|---|---|---|
| Nil | Nil | Nil | This action does not require any parameter. |
Structure of Response
| Status | Response |
|---|---|
| Success | { "status": "success", "message": "Cart refreshed" } |
| Failed | { "status": "failed", "message": "Unable to refresh the cart" } |
| Unexpected Error | { "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" } |
Example Usage
await Superfans.actions.refreshCart();
Superfans.listeners.onCartUpdated(() => {
const cart = Superfans.variables.cart;
});Best Practices
- Call after
updateCartPropertiesif the UI should show the latest cart. - Pair with
Superfans.listeners.onCartUpdatedinstead of polling. - Re-read
Superfans.variables.cartinside the listener.
Caveats
- This action does not open the cart page.
- Cart data on
Superfans.variables.cartis read-only. - The cart update may arrive asynchronously.
Updated about 7 hours ago
Did this page help you?