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

Structure of Response

StatusResponse
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

  1. Call after updateCartProperties if the UI should show the latest cart.
  2. Pair with Superfans.listeners.onCartUpdated instead of polling.
  3. Re-read Superfans.variables.cart inside the listener.

Caveats

  1. This action does not open the cart page.
  2. Cart data on Superfans.variables.cart is read-only.
  3. The cart update may arrive asynchronously.

Did this page help you?