Sana Assistant (online)
Table of Contents

Products Added To Basket event

This article provides reference material about the "Products Added To Basket" event. The Sana core system emits this event when products are added to the basket.

The custom RxJS operator

The custom RxJS operator that filters an Observable of actions into the products added to basket Observable.

type AddedToBasketProduct = {
  id: string;
  quantity: number | null;
  price: number | null;
};

type ProductsAddedToBasketInfo = {
  products: Array<AddedToBasketProduct>;
};

export function onProductsAddedToBasket(): (source$: Observable<Action>) => Observable<ProductsAddedToBasketInfo>;
Property Type Description
products AddedToBasketProduct[] The products added to the basket.

AddedToBasketProduct:

Property Type Description
id string The unique product identifier.
quantity number | null The quantity added to the basket.
price number | null The unit price of the product. Can be null if user can't see prices or prices are not available on the webshop.

Example:

import { onProductsAddedToBasket } from 'sana/events';

const productsAddedToBasket$ = action$.pipe(
  onProductsAddedToBasket(),
  map(result => notifyProductsAddedToBasket(result.products)),
);