Skip to content
On this page

useWishlist ​

Definition ​

Composable to manage wishlist

Basic usage ​

ts
const { 
 items,
 count,
 mergeWishlistProducts,
 getWishlistProducts,
 clearWishlist 
} = useWishlist();

Signature ​

ts
export function useWishlist(): UseWishlistReturn 

Return type ​

See UseWishlistReturn
ts
export type UseWishlistReturn = {
  /**
   * Merge products with wishlist between async (API) and sync (localstorage) wishlists
   */
  mergeWishlistProducts(): void;
  /**
   * Get products list added to wishlist
   */
  getWishlistProducts(): void;
  /**
   * Clear wishlist
   */
  clearWishlist(): void;
  /**
   * Wishlist items (Product IDs)
   */
  items: ComputedRef<string[]>;
  /**
   * Wishlist items count
   */
  count: ComputedRef<number>;
};

Properties ​

NameTypeDescription
items
ComputedRef<Array<string>>
Wishlist items (Product IDs)
count
ComputedRef<number>
Wishlist items count

Methods ​

NameTypeDescription
mergeWishlistProducts
void
Merge products with wishlist between async (API) and sync (localstorage) wishlists
getWishlistProducts
void
Get products list added to wishlist
clearWishlist
void
Clear wishlist
useWishlist has loaded