Skip to content
On this page

useProduct ​

Definition ​

Composable for product management.

Basic usage ​

ts
const { 
 product,
 configurator,
 changeVariant 
} = useProduct(product, configurator);

Signature ​

ts
export function useProduct(
  product?: Ref<Schemas["Product"]> | Schemas["Product"],
  configurator?: Ref<Schemas["PropertyGroup"][]> | Schemas["PropertyGroup"][],
): UseProductReturn 

Parameters ​

NameTypeDescription
product
Ref<> | 
configurator
Ref<Array<>> | Array<>

Return type ​

See UseProductReturn
ts
export type UseProductReturn = {
  /**
   * Returns product object
   * {@link Product} object
   */
  product: ComputedRef<Schemas["Product"]>;
  /**
   * {@link PropertyGroup} array that defines the product possible configurations
   */
  configurator: ComputedRef<Schemas["PropertyGroup"][]>;
  /**
   * Merges the current product with the new variant data
   * @param variant - {@link Product} object with the new variant data
   */
  changeVariant(variant: Partial<Schemas["Product"]>): void;
};

Properties ​

NameTypeDescription
product
ComputedRef<>
Returns product object{@link Product} object
configurator
ComputedRef<Array<>>
{@link PropertyGroup} array that defines the product possible configurations

Methods ​

NameTypeDescription
changeVariant
void
Merges the current product with the new variant data
useProduct has loaded