Skip to main content
Skip to main content

formatVariantPrice

This utility function can be used to compute the price of a variant for a region and retrieve the formatted amount. For example, $20.00.

Example

src/Products.ts
import React from "react"
import { formatVariantPrice } from "medusa-react"
import { Product, ProductVariant } from "@medusajs/medusa"

const Products = () => {
// ...
return (
<ul>
{products?.map((product: Product) => (
<li key={product.id}>
{product.title}
<ul>
{product.variants.map((variant: ProductVariant) => (
<li key={variant.id}>
{formatVariantPrice({
variant,
region, // should be retrieved earlier
})}
</li>
))}
</ul>
</li>
))}
</ul>
)
}

Parameters

Options to format the variant's price.

Returns

stringstringRequired
The formatted price.
Was this section helpful?