Skip to content
On this page

useProductReviews

Definition

Composable for listing customer orders.

Basic usage

ts
const { 
 productReviews,
 addReview,
 loadProductReviews 
} = useProductReviews(product);

Signature

ts
export function useProductReviews(
  product: Ref<Product>,
): UseProductReviewsReturn 

Parameters

NameTypeDescription
product
Ref<Product>

Return type

See UseProductReviewsReturn
ts
export type UseProductReviewsReturn = {
  /**
   * All reviews added to the product
   */
  productReviews: ComputedRef<ProductReview[]>;
  /**
   * Adds a review to the product
   * @param data `title` - review title, `content` - review content, `points` - review points (range of 1-5)
   * @returns
   */
  addReview(data: {
    title: string;
    content: string;
    points: number;
  }): Promise<void>;
  /**
   * Fetches the reviews list and assigns the result to the `productReviews` property
   * @param parameters {@link ShopwareSearchParams}
   * @returns
   */
  loadProductReviews(parameters?: ShopwareSearchParams): Promise<void>;
};

Properties

NameTypeDescription
productReviews
ComputedRef<Array<ProductReview>>
All reviews added to the product

Methods

NameTypeDescription
addReview
Promise<void>
Adds a review to the product
loadProductReviews
Promise<void>
Fetches the reviews list and assigns the result to the `productReviews` property
useProductReviews has loaded