@coveo/headless-react
    Preparing search index...

    Interface CartActionCreators

    The cart action creators.

    interface CartActionCreators {
        emitCartActionEvent(
            payload: CartActionDetails,
        ): AsyncThunkAction<
            void,
            CartActionDetails,
            AsyncThunkCommerceOptions<CommerceEngineState>,
        >;
        emitPurchaseEvent(
            payload: Transaction,
        ): AsyncThunkAction<
            void,
            Transaction,
            AsyncThunkCommerceOptions<CommerceEngineState>,
        >;
        purchase(): { payload: void; type: string };
        setItems(
            payload: SetItemsPayload,
        ): { payload: SetItemsPayload; type: string };
        updateItemQuantity(
            payload: CartItemWithMetadata,
        ): { payload: CartItemWithMetadata; type: string };
    }
    Index

    Methods

    • Emits an ec.cartAction analytics event.

      Should be dispatched before the updateItemQuantity action.

      Parameters

      • payload: CartActionDetails

        The action creator payload.

      Returns AsyncThunkAction<
          void,
          CartActionDetails,
          AsyncThunkCommerceOptions<CommerceEngineState>,
      >

      A dispatchable action.

    • Emits an ec.purchase analytics event with the current cart state.

      Should be dispatched before the purchase action.

      Parameters

      • payload: Transaction

        The action creator payload.

      Returns AsyncThunkAction<
          void,
          Transaction,
          AsyncThunkCommerceOptions<CommerceEngineState>,
      >

      A dispatchable action.

    • Marks the items in the cart as purchased and empties the cart.

      Should be dispatched after the emitPurchase action.

      Returns { payload: void; type: string }

      A dispatchable action.

    • Sets the items in the cart.

      Parameters

      Returns { payload: SetItemsPayload; type: string }

      A dispatchable action.

    • Updates the quantity of an item in the cart.

      Should be dispatched after the emitCartAction action.

      Parameters

      • payload: CartItemWithMetadata

        The action creator payload.

      Returns { payload: CartItemWithMetadata; type: string }

      A dispatchable action.