Skip to main content
Skip to main content

computeAmount

This utility function can be used to compute the price of an amount for a region and retrieve the amount without formatting. For example, 20. This function is used by formatAmount before applying the price formatting.

The main difference between this utility function and computeVariantPrice is that you don’t need to pass a complete variant object. This can be used with any number.

Example

src/MyComponent.ts
import React from "react"
import { computeAmount } from "medusa-react"

const MyComponent = () => {
// ...
return (
<div>
{computeAmount({
amount,
region, // should be retrieved earlier
})}
</div>
)
}

Parameters

params0ComputeAmountParamsRequired
The options to compute the amount.

Returns

numbernumberRequired
The computed amount.
Was this section helpful?