npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

medusa-product-reviews

v1.0.1

Published

A plugin that enables customer product reviews for your Medusa store.

Downloads

116

Readme

medusa-product-reviews

Documentation

If you are not familiar with Medusa, you can learn more on the project web site.

What is it?

A plugin that enables customer product reviews for your Medusa store.

How to install?

  1. Install the package with yarn add medusa-product-reviews or npm i medusa-product-reviews
  2. In medusa-config.js, add the plugin to the plugins array and set enableUI
const plugins = [
  // ... other plugins
  {
    resolve: `medusa-product-reviews`,
    options: {
      enableUI: true
    }
  }
]
  1. Run migrations, e.g. npx medusa migrations run (see: https://docs.medusajs.com/development/entities/migrations/overview) as plugin uses new tables.

  2. Start project

  • After installation of a plugin, you will see new option on the sidebar named Reviews.
  • You can check reviews for each product in single product details page
  • You can check reviews for order on order details page

API Endpoints

Store API Endpoints

  1. GET /store/product-reviews

    • Description: Retrieves a list of product reviews based on the provided query parameters.
    • Query Parameters:
      • order_id: (Optional) Filters reviews by a specific order.
      • product_id: (Optional) Filters reviews by a specific product.
      • customer_id: (Optional) Filters reviews by a specific customer.
      • rating: (Optional) Filters reviews by a specific rating.
      • limit: (Optional) Number of reviews to return.
      • offset: (Optional) Number of reviews to skip before starting to return results.
    • Response: Returns a JSON object containing an array of review objects and the total count.
    • Sample Response:
      {
        "reviews": [
          {
            "id": "string",
            "product_id": "string",
            "customer_id": "string",
            "order_id": "string",
            "rating": 5,
            "content": "Great product!",
            "images": ["image1.jpg", "image2.jpg"],
            "created_at": "2023-08-24T12:34:56.789Z",
            "updated_at": "2023-08-24T12:34:56.789Z"
          }
        ],
        "count": 1
      }
  2. GET /store/product-reviews/stats

    • Description: Retrieves statistics for product reviews, including average rating and distribution by rating.
    • Query Parameters:
      • product_id: (Required) The product ID for which to retrieve statistics.
    • Response: Returns a JSON object containing review statistics.
    • Sample Response:
      {
        "stats": {
          "product_id": "string",
          "average": 4.5,
          "count": 10,
          "by_rating": [
            { "rating": 5, "count": 6 },
            { "rating": 4, "count": 3 },
            { "rating": 3, "count": 1 }
          ]
        }
      }
  3. POST /store/product-reviews

    • Description: Creates a new product review.
    • Request Body:
      • product_id: (Required) The ID of the product being reviewed.
      • order_id: (Required) The ID of the order associated with the review.
      • rating: (Required) The rating given to the product.
      • content: (Optional) The content of the review.
      • images: (Optional) An array of image URLs or files associated with the review.
    • Response: Returns a JSON object containing the newly created review.
    • Sample Response:
      {
        "review": {
          "id": "string",
          "product_id": "string",
          "customer_id": "string",
          "order_id": "string",
          "rating": 5,
          "content": "Great product!",
          "images": ["image1.jpg", "image2.jpg"],
          "created_at": "2023-08-24T12:34:56.789Z",
          "updated_at": "2023-08-24T12:34:56.789Z"
        }
      }
  4. POST /store/product-reviews/:product_review_id

    • Description: Updates an existing product review by ID.
    • Request Body:
      • product_id: (Required) The ID of the product being reviewed.
      • order_id: (Required) The ID of the order associated with the review.
      • rating: (Required) The rating given to the product.
      • content: (Optional) The updated content of the review.
      • images: (Optional) An array of updated image URLs or files associated with the review.
    • Response: Returns a JSON object containing the updated review.
    • Sample Response:
      {
        "review": {
          "id": "string",
          "product_id": "string",
          "customer_id": "string",
          "order_id": "string",
          "rating": 5,
          "content": "Updated review content.",
          "images": ["image1.jpg", "image2.jpg"],
          "created_at": "2023-08-24T12:34:56.789Z",
          "updated_at": "2023-08-24T12:34:56.789Z"
        }
      }

Admin API Endpoints

  1. GET /admin/product-reviews/stats

    • Description: Retrieves statistics for product reviews, including average rating and distribution by rating.
    • Query Parameters:
      • product_id: (Required) The product ID for which to retrieve statistics.
    • Response: Returns a JSON object containing review statistics (same format as store endpoint).
  2. GET /admin/product-reviews

    • Description: Retrieves a list of product reviews based on the provided query parameters.
    • Query Parameters: Same as the GET /store/product-reviews endpoint.
    • Response: Returns a JSON object containing an array of review objects and the total count.
  3. POST /admin/product-reviews/:product_review_id

    • Description: Updates the reply to an existing product review by ID.
    • Request Body:
      • reply: (Required) The updated reply to the review.
    • Response: Returns a JSON object containing the updated review with the new reply.
  4. DELETE /admin/product-reviews/:id

    • Description: Deletes an existing product review by ID.
    • Response: Returns a JSON object indicating success.
    • Sample Response:
      {
        "success": true
      }

Objects

  • Product Review:

    {
      "id": "string",
      "product_id": "string",
      "customer_id": "string",
      "order_id": "string",
      "rating": 5,
      "content": "Great product!",
      "reply": "Thank you for your feedback!",
      "images": ["image1.jpg", "image2.jpg"],
      "created_at": "2023-08-24T12:34:56.789Z",
      "updated_at": "2023-08-24T12:34:56.789Z",
      "deleted_at": null
    }

    Proposals, bugs, improvements

If you have an idea, what could be the next highest priority functionality, do not hesistate raise issue here: Github issues

License

MIT

Pro version

The Pro version of medusa-documents expands on the features of the free version with more advanced capabilities such as:

  • option to show/hide reviews
  • delete unwanted reviews
  • and a lot more.

The Pro version is available under commercial licence - contact abdullah-afzal for more information.

Hide Pro version tab

We show what advanced features we offer in "Pro version" tab. We try to keep it non-intruisive, but if you feel it differently, you can always hide this tab by setting following environment variable: MEDUSA_ADMIN_PRODUCTS_REVIEWS_HIDE_PRO=true

After restarting your admin application, you shall have this tab hidden.


© 2024 abdullah-afzal