feature-product hooks
The components already use these hooks. Reach for them when you build your own UI on the same data. Open a hook for its options and what it returns.
Changing data
useAddOnSelectionThe add-ons the shopper ticked, for ProductDetailAddOns and the add-to-cart button.
import { useAddOnSelection } from "@evolve-storefront/feature-product/hooks";function useAddOnSelection( addOns: readonly ProductAddOn[],): { selected: string[]; onSelectedChange: (selected: string[]) => void; clear: () => void;}Returns { selected: string[]; onSelectedChange: (selected: string[]) => void; clear: () => void; }
Other hooks
useBundleSelectionThe bundle the shopper put together, for ProductDetailBundle and the add button.
import { useBundleSelection } from "@evolve-storefront/feature-product/hooks";function useBundleSelection( args: { sku: string | null; items: readonly ProductBundleItem[]; },): ProductBundleSelection| Option | Type | Description |
|---|---|---|
sku | string | null | |
items | readonly ProductBundleItem[] |
Returns ProductBundleSelection
useRecentlyViewedThe shopper's recently viewed products, newest first, and record to add one.
import { useRecentlyViewed } from "@evolve-storefront/feature-product/hooks";function useRecentlyViewed<Item>( options?: RecentlyViewedOptions,): { products: Item[]; record: (product: Item) => void;}| Option | Type | Description |
|---|---|---|
storageKey? | string | The |
limit? | number | How many products the history keeps. |
Returns { products: Item[]; record: (product: Item) => void; }
useProductListingThe enclosing ProductListingProvider's facets and navigation.
import { useProductListing } from "@evolve-storefront/feature-product/product-listing";function useProductListing(): ProductListingContextValueReturns ProductListingContextValue
useProductListingLayoutThe layout choice of the enclosing ProductListingLayout.
import { useProductListingLayout } from "@evolve-storefront/feature-product/product-listing";function useProductListingLayout(): LayoutContextValueReturns LayoutContextValue
useProductListingTableQuantityThe quantity of the enclosing table row, for the add button a site renders in it.
import { useProductListingTableQuantity } from "@evolve-storefront/feature-product/product-listing";function useProductListingTableQuantity(): numberReturns number

