mercurjs / mercur

JavaScript Open Source
Multi-Vendor Marketplace Accelerator build on top of Medusa.js. Mercur simplifies the path to your own customized, multi-vendor marketplace.
https://mercurjs.com
MIT License
153 stars 15 forks source link

Storefront product prices show as NaN since product.variants is assumed to contain calulatedPrices but the pricingService.calculatePrices function is never called #10

Closed NicolasGorga closed 6 days ago

NicolasGorga commented 3 months ago

Hello Mercur team!

After having setup a product, its variants and the prices for these, I am getting "NaN" inside the product detail page and I assume this will happen anywhere the variant is expected to have calulcatedPrices, since the pricingService.calulatePrices() function is never called.

I see that inside src/modules/products/components/product-price/index.ts line 19 you use variantPrice and cheapestPrice props from the returned value of getProductPrice function, defined in src/lib/util/get-product-price.ts

The function cheapestPrice() defined in line 27, casts the product.variants as CalculatedVariant[], but the variants don't contain calculatedPrice properties, since Medusa's calculatePrices of pricingService is never called before, therefore, properties like 'calculated_price' and 'original_price' are undefined.

The only place i see pricingService.calculatePrices() get called is inside src/lib/util/get-prices-by-price-set-id.ts function getPricesByPriceSetId but the problem is that if i do "Find All References" in VS Code i see this isn't used anywhere, which aligns with the behaviour i am seeing.

Could you confirm if i am understanding this correctly and is in fact a bug?