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
The variant's details.
The region's details.
Returns
numbernumberRequiredThe variant's price in a region.
Was this section helpful?