Skip to content
Shopware

useProductReviews

useProductReviews

Category:
Product

Composable for listing customer orders.

Types

ts
export function useProductReviews(
  product: Ref<Schemas["Product"]>,
): UseProductReviewsReturn

source code

ts
export type UseProductReviewsReturn = {
  /**
   * All reviews added to the product
   */
  productReviews: ComputedRef<Schemas["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 Schemas["Criteria"]}
   * @returns
   */
  loadProductReviews(
    parameters?: Schemas["Criteria"],
  ): Promise<
    operations["readProductReviews post /product/{productId}/reviews"]["response"]
  >;
};

source code