docs
  1. Features
  2. Recommendations
  3. Composables

Composables

Interfaces

UseRecentlyViewedProductsOptions

This composable can be used to track a short history of products a customer has previously viewed using local storage. It maintains up to 10 recently viewed products and provides methods to add new products and fetch their full details.

Param

An object containing parameters and options for the loading the products.

Param

The fields to include in the response.

Param

The price promotion key.

Properties

PropertyType
pricePromotionKey?string
with?ProductWith

UseRecentlyViewedProductsReturn

Properties

PropertyTypeDescription
addProductId(productId: number) => voidAdds a product id to the list of recently viewed products and persists it to local storage. Because this function uses local storage, it is not available on the server. Throws Error if the function is called on the server.
errorRef< | Error | undefined>A reactive container for any errors that occur during fetching.
loadingRef<boolean>A reactive flag indicating if the product data is being fetched.
loadMissingProducts() => Promise<void>Loads products based on the product ids previously added. Initially all products within the persisted list are loaded. Subsequent calls only load products that are not already loaded. Because this function uses local storage, it is not available on the server. Throws Error if the function is called on the server.
productsRef<Product[]>A reactive array of the fetched, full Product objects.
statusRef<AsyncDataRequestStatus>A string indicating the status of the data request

Functions

useRecentlyViewedProducts()

Parameters

Returns

UseRecentlyViewedProductsReturn