Skip to content

Commit

Permalink
feat(core): show original price on Cart
Browse files Browse the repository at this point in the history
  • Loading branch information
jorgemoya committed May 13, 2024
1 parent 15e4b82 commit 7adfa70
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 6 deletions.
5 changes: 5 additions & 0 deletions .changeset/kind-maps-attend.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@bigcommerce/catalyst-core": patch
---

Show original price of Cart item when on sale
31 changes: 25 additions & 6 deletions core/app/[locale]/(default)/cart/_components/cart-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ const PhysicalItemFragment = graphql(`
currencyCode
value
}
originalPrice {
currencyCode
value
}
selectedOptions {
__typename
entityId
Expand Down Expand Up @@ -71,6 +75,10 @@ const DigitalItemFragment = graphql(`
currencyCode
value
}
originalPrice {
currencyCode
value
}
selectedOptions {
__typename
entityId
Expand Down Expand Up @@ -212,12 +220,23 @@ export const CartItem = async ({ currencyCode, product }: Props) => {
</div>

<div className="flex flex-col gap-2 md:items-end">
<p className="text-lg font-bold">
{format.number(product.extendedSalePrice.value, {
style: 'currency',
currency: currencyCode,
})}
</p>
<div>
{product.originalPrice.value &&
product.originalPrice.value !== product.extendedSalePrice.value ? (
<p className="text-lg font-bold line-through">
{format.number(product.originalPrice.value, {
style: 'currency',
currency: currencyCode,
})}
</p>
) : null}
<p className="text-lg font-bold">
{format.number(product.extendedSalePrice.value, {
style: 'currency',
currency: currencyCode,
})}
</p>
</div>

<NextIntlClientProvider locale={locale} messages={{ Cart: messages.Cart ?? {} }}>
<ItemQuantity product={product} />
Expand Down

0 comments on commit 7adfa70

Please sign in to comment.