Skip to main content
Skip to main content

getVariantPrice

This utility function is used to retrieve a variant's price in a region. It doesn't take into account taxes or any options, so you typically wouldn't need this function on its own. It's used by the computeVariantPrice function to retrieve the variant's price in a region before computing the correct price for the options provided.

Example

src/Products.ts
import React from "react"
import { getVariantPrice } 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}>
{getVariantPrice(
variant,
region, // should be retrieved earlier
)}
</li>
))}
</ul>
</li>
))}
</ul>
)
}

Parameters

variantProductVariantInfoRequired
The variant's details.
regionRegionInfoRequired
The region's details.

Returns

numbernumberRequired
The variant's price in a region.
Was this section helpful?