mirror of
https://github.com/vercel/commerce.git
synced 2025-05-19 16:07:01 +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,
|
||||
pricing,
|
||||
}) => {
|
||||
const variantPrice = pricing[0]?.price ?? pricing[0]?.minPrice
|
||||
let variantPrice = pricing[0]?.price ?? pricing[0]?.minPrice
|
||||
|
||||
if (variantPrice === undefined) {
|
||||
variantPrice = 0
|
||||
}
|
||||
|
||||
return {
|
||||
id: variantId,
|
||||
@ -60,20 +64,22 @@ const normalizeProductVariants = (variants: [CatalogProductVariant]) => {
|
||||
price: variantPrice,
|
||||
listPrice: pricing[0]?.compareAtPrice?.amount ?? variantPrice,
|
||||
requiresShipping: true,
|
||||
// options: options?.map(({ attributeLabel, optionTitle }: CatalogProductVariant) =>
|
||||
// normalizeProductOption({
|
||||
// id: _id,
|
||||
// name: attributeLabel,
|
||||
// values: [optionTitle],
|
||||
// })
|
||||
// ) ?? [],
|
||||
options: [
|
||||
{
|
||||
__typename: 'MultipleChoiceOption',
|
||||
displayName: attributeLabel,
|
||||
values: [{ label: optionTitle }],
|
||||
},
|
||||
],
|
||||
options:
|
||||
options?.map(
|
||||
({ _id, attributeLabel, optionTitle }: CatalogProductVariant) =>
|
||||
normalizeProductOption({
|
||||
id: _id,
|
||||
name: attributeLabel,
|
||||
values: [optionTitle],
|
||||
})
|
||||
) ?? [],
|
||||
// options: [
|
||||
// {
|
||||
// __typename: 'MultipleChoiceOption',
|
||||
// displayName: attributeLabel,
|
||||
// values: [{ label: optionTitle }],
|
||||
// },
|
||||
// ],
|
||||
}
|
||||
}
|
||||
)
|
||||
|
Loading…
x
Reference in New Issue
Block a user