Update Cart Properties

Updates cart properties. Use truncateValue to pass prefixes that should be truncated from cart property values.

Description

The updateCartProperties() action updates cart properties. Use truncateValue to pass prefixes that should be truncated from cart property values.

Function Signature

await Superfans.actions.updateCartProperties({
  truncateValue: ["MOBILE_APP_"]
});
ParameterTypeRequiredDescription
truncateValueString[]YesArray of prefixes to truncate from cart property values. Each item must be a non-empty string.

Structure of Response

StatusResponse
Success{ "status": "success", "message": "Cart properties updated" }
Invalid Params{ "status": "error", "errorId": 400, "errorHandle": "invalid-params", "message": "Invalid params" }
Unexpected Error{ "status": "error", "errorId": 500, "errorHandle": "unknown-error", "message": "Something unexpected happened" }

Example Usage

await Superfans.actions.updateCartProperties({
  truncateValue: ["MOBILE_APP_"]
});

Best Practices

  1. Pass only the prefixes you want truncated.
  2. After updating properties, call Superfans.actions.refreshCart() if the UI needs the latest cart.
  3. Pair with Superfans.listeners.onCartUpdated to re-render cart attributes.

Caveats

  1. truncateValue is required and must be an array of non-empty strings.
  2. This action does not open the cart.
  3. Cart data on Superfans.variables.cart is read-only; use this action to change properties.

Did this page help you?