mirror of
https://github.com/vercel/commerce.git
synced 2025-05-20 08:26:59 +00:00
fix: capitalize currency code
This commit is contained in:
parent
efc6dd4b1a
commit
4994c029fc
@ -18,7 +18,7 @@ import {
|
|||||||
SelectedOption
|
SelectedOption
|
||||||
} from './types';
|
} from './types';
|
||||||
|
|
||||||
const ENDPOINT = process.env.MEDUSA_BACKEND_API;
|
const ENDPOINT = process.env.NEXT_PUBLIC_MEDUSA_BACKEND_API;
|
||||||
|
|
||||||
export default async function medusaRequest(
|
export default async function medusaRequest(
|
||||||
method: string,
|
method: string,
|
||||||
@ -67,7 +67,7 @@ const reshapeCart = (cart: MedusaCart): Cart => {
|
|||||||
const lines = cart?.items?.map((item) => reshapeLineItem(item)) || [];
|
const lines = cart?.items?.map((item) => reshapeLineItem(item)) || [];
|
||||||
const totalQuantity = lines.length;
|
const totalQuantity = lines.length;
|
||||||
const checkoutUrl = '/';
|
const checkoutUrl = '/';
|
||||||
const currencyCode = cart.region?.currency_code || 'USD';
|
const currencyCode = cart.region?.currency_code.toUpperCase() || 'USD';
|
||||||
|
|
||||||
let subtotalAmount = '0';
|
let subtotalAmount = '0';
|
||||||
if (cart.subtotal && cart.region) {
|
if (cart.subtotal && cart.region) {
|
||||||
@ -145,7 +145,7 @@ const reshapeLineItem = (lineItem: MedusaLineItem): CartItem => {
|
|||||||
lineItem.total,
|
lineItem.total,
|
||||||
lineItem.variant?.prices?.[0]?.currency_code
|
lineItem.variant?.prices?.[0]?.currency_code
|
||||||
).toString(),
|
).toString(),
|
||||||
currencyCode: lineItem.variant?.prices?.[0]?.currency_code || 'EUR'
|
currencyCode: lineItem.variant?.prices?.[0]?.currency_code.toUpperCase() || 'EUR'
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const quantity = lineItem.quantity;
|
const quantity = lineItem.quantity;
|
||||||
@ -164,14 +164,14 @@ const reshapeProduct = (product: MedusaProduct): Product => {
|
|||||||
let amount = '0';
|
let amount = '0';
|
||||||
let currencyCode = 'USD';
|
let currencyCode = 'USD';
|
||||||
if (variant && variant.prices?.[0]?.amount) {
|
if (variant && variant.prices?.[0]?.amount) {
|
||||||
currencyCode = variant.prices?.[0]?.currency_code ?? 'USD';
|
currencyCode = variant.prices?.[0]?.currency_code.toUpperCase() ?? 'USD';
|
||||||
amount = convertToDecimal(variant.prices[0].amount, currencyCode).toString();
|
amount = convertToDecimal(variant.prices[0].amount, currencyCode).toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
const priceRange = {
|
const priceRange = {
|
||||||
maxVariantPrice: {
|
maxVariantPrice: {
|
||||||
amount,
|
amount,
|
||||||
currencyCode: product.variants?.[0]?.prices?.[0]?.currency_code ?? ''
|
currencyCode: product.variants?.[0]?.prices?.[0]?.currency_code.toUpperCase() ?? ''
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const updatedAt = product.updated_at;
|
const updatedAt = product.updated_at;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user