Skip to content

Commit 6e8d4e1

Browse files
authored
fix: discount 100% ordersummary (#5770)
1 parent 91c824a commit 6e8d4e1

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.changeset/sharp-ears-fold.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@ultraviolet/plus": patch
3+
---
4+
5+
`OrderSummary`: `discount=1` should be interpreted as "100%", not "1€"

packages/plus/src/components/OrderSummary/helpers.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ export const calculatePrice = ({
5555
Math.max(amount - amountFree, 0)
5656

5757
const finalValue =
58-
valueBeforeDiscount * (1 - (discount < 1 ? discount : 0)) -
59-
(discount >= 1 ? Math.abs(discount) : 0)
58+
valueBeforeDiscount * (1 - (discount <= 1 ? discount : 0)) -
59+
(discount > 1 ? Math.abs(discount) : 0)
6060

6161
return finalValue
6262
}
@@ -126,12 +126,12 @@ export const calculateCategoryPrice = (
126126
) || [0, 0]
127127

128128
const discountedPriceMin =
129-
category.discount && category.discount < 1
129+
category.discount && category.discount <= 1
130130
? categoryPrice[0] * category.discount
131131
: categoryPrice[0] - (category.discount ?? 0)
132132

133133
const discountedPriceMax =
134-
category.discount && category.discount < 1
134+
category.discount && category.discount <= 1
135135
? categoryPrice[1] * category.discount
136136
: categoryPrice[1] - (category.discount ?? 0)
137137

@@ -141,7 +141,7 @@ export const calculateCategoryPrice = (
141141

142142
categoryPrice.map(price =>
143143
Math.max(
144-
category.discount && category.discount < 1
144+
category.discount && category.discount <= 1
145145
? price * category.discount
146146
: price - (category.discount ?? 0),
147147
0,

0 commit comments

Comments
 (0)