medusajs / medusa

The world's most flexible commerce platform.
https://medusajs.com
MIT License
26.24k stars 2.67k forks source link

Documentation not update Digital Products For the Frontend #6589

Closed NoahPerez closed 7 months ago

NoahPerez commented 9 months ago

Preliminary Checks

Issue Summary

in the Docs it say , but medusaRequest seems that doesn't exist WhatsApp Image 2024-03-05 at 17 36 47

Then, add in src/lib/data/index.ts Copy to Clipboard a new function that retrieves the product media of the product variant being viewed:

src/lib/data/index.ts

import { ProductMedia, } from "types/product-media" import { Variant } from "../../types/medusa"

// ... rest of the functions

export async function getProductMediaPreviewByVariant( variant: Variant ): Promise { const { product_medias, } = await medusaRequest( "GET", /product-media, { query: { variant_ids: variant.id, }, } ) .then((res) => res.body) .catch((err) => { throw err })

return product_medias[0] }

Link to the Docs https://docs.medusajs.com/recipes/digital-products#preview-digital-product

How can this issue be resolved?

  1. Update the Docs
  2. Maybe it is a new function that is not aware of
  3. ...

Are you interested in working on this issue?

juniormayhe commented 7 months ago

Yes, the digital product guide seems out of sync with the documentation. Besides missing mediaRequest, there are other cases.

I think it is necessary to create a new app according to the docs:

pnpx create-medusa-app@latest --with-nextjs-starter

Then try to follow along with the Digital Products docs and fix the docs accordingly, for both the backend and storefront: Digital Products Documentation.

Meanwhile, a warning at the top of the page could be added to inform that the document is deprecated.

shahednasser commented 7 months ago

Thank you both for reporting this issue. Seems like medusaRequest was renamed to medusaClient in the Next.js storefront. Sorry for the inconvenience. Will look into updating the Next.js storefront code in the recipe