mirror of
https://github.com/vercel/commerce.git
synced 2025-05-20 00:16:59 +00:00
add fallback value for variant price
Signed-off-by: Loan Laux <loan@outgrow.io>
This commit is contained in:
parent
652a45468b
commit
946545b091
@ -51,7 +51,11 @@ const normalizeProductVariants = (variants: [CatalogProductVariant]) => {
|
|||||||
title,
|
title,
|
||||||
pricing,
|
pricing,
|
||||||
}) => {
|
}) => {
|
||||||
const variantPrice = pricing[0]?.price ?? pricing[0]?.minPrice
|
let variantPrice = pricing[0]?.price ?? pricing[0]?.minPrice
|
||||||
|
|
||||||
|
if (variantPrice === undefined) {
|
||||||
|
variantPrice = 0
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
id: variantId,
|
id: variantId,
|
||||||
@ -60,20 +64,22 @@ const normalizeProductVariants = (variants: [CatalogProductVariant]) => {
|
|||||||
price: variantPrice,
|
price: variantPrice,
|
||||||
listPrice: pricing[0]?.compareAtPrice?.amount ?? variantPrice,
|
listPrice: pricing[0]?.compareAtPrice?.amount ?? variantPrice,
|
||||||
requiresShipping: true,
|
requiresShipping: true,
|
||||||
// options: options?.map(({ attributeLabel, optionTitle }: CatalogProductVariant) =>
|
options:
|
||||||
// normalizeProductOption({
|
options?.map(
|
||||||
// id: _id,
|
({ _id, attributeLabel, optionTitle }: CatalogProductVariant) =>
|
||||||
// name: attributeLabel,
|
normalizeProductOption({
|
||||||
// values: [optionTitle],
|
id: _id,
|
||||||
// })
|
name: attributeLabel,
|
||||||
// ) ?? [],
|
values: [optionTitle],
|
||||||
options: [
|
})
|
||||||
{
|
) ?? [],
|
||||||
__typename: 'MultipleChoiceOption',
|
// options: [
|
||||||
displayName: attributeLabel,
|
// {
|
||||||
values: [{ label: optionTitle }],
|
// __typename: 'MultipleChoiceOption',
|
||||||
},
|
// displayName: attributeLabel,
|
||||||
],
|
// values: [{ label: optionTitle }],
|
||||||
|
// },
|
||||||
|
// ],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user