CartPredictor

cart · /react·type

A function that projects the entire cart after a pending mutation has been applied to the lines. Use it to recompute cart-level aggregates — such as total quantity or subtotal — that depend on the mutated line set.

Definition

@nordcom/commerce-cart
type CartPredictor = (projection: Cart<TExt>, mutation: CartMutation, ctx: PredictorCtx<TExt>) => Cart<TExt>;

(projection: Cart<TExt>, mutation: CartMutation, ctx: PredictorCtx<TExt>) => Cart<TExt>

Example

const predictors = {
  cart: [quantitySumPredictor(), subtotalPredictor()],
};

CartDevtools CartFormProps CartProviderProps AppCartConfig BaseCartActions BuyerIdentityActions CartActions CartAttributeActions

Metadata@nordcom/commerce-cart@0.2.2Open in GitHub ↗

On this page