Appearance
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 ​
Name | Type | Description |
---|---|---|
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 ​
Name | Type | Description |
---|---|---|
product | ComputedRef<> | Returns product object{@link Product} object |
configurator | ComputedRef<Array<>> | {@link PropertyGroup} array that defines the product possible configurations |
Methods ​
Name | Type | Description |
---|---|---|
changeVariant | void | Merges the current product with the new variant data |