@@ -11,7 +11,8 @@ export const getCartDiscountendTotal = (cart: Store['cart']) => {
11
11
const total = cartProductsWithQuantity ( cart ) . reduce (
12
12
( total , productWithQty ) =>
13
13
total +
14
- productWithQty . product ! . price . discounted . amount * productWithQty . quantity ,
14
+ ( productWithQty . product ?. price . discounted . amount || 0 ) *
15
+ productWithQty . quantity ,
15
16
0
16
17
) ;
17
18
return formatPrice ( total , 2 ) ;
@@ -21,7 +22,8 @@ export const getCartRegularTotal = (cart: Store['cart']) => {
21
22
const total = cartProductsWithQuantity ( cart ) . reduce (
22
23
( total , productWithQty ) =>
23
24
total +
24
- productWithQty . product ! . price . regular . amount * productWithQty . quantity ,
25
+ ( productWithQty . product ?. price . regular . amount || 0 ) *
26
+ productWithQty . quantity ,
25
27
0
26
28
) ;
27
29
return formatPrice ( total , 2 ) ;
@@ -31,8 +33,8 @@ export const getCartSavingTotal = (cart: Store['cart']) => {
31
33
const total = cartProductsWithQuantity ( cart ) . reduce (
32
34
( total , productWithQty ) =>
33
35
total +
34
- ( productWithQty . product ! . price . regular . amount -
35
- productWithQty . product ! . price . discounted . amount ) *
36
+ ( ( productWithQty . product ? .price . regular . amount || 0 ) -
37
+ ( productWithQty . product ? .price . discounted . amount || 0 ) ) *
36
38
productWithQty . quantity ,
37
39
0
38
40
) ;
@@ -43,7 +45,8 @@ export const getCartTotal = (cart: Store['cart'], promo: number) => {
43
45
const total = cartProductsWithQuantity ( cart ) . reduce (
44
46
( total , productWithQty ) =>
45
47
total +
46
- productWithQty . product ! . price . discounted . amount * productWithQty . quantity ,
48
+ ( productWithQty . product ?. price . discounted . amount || 0 ) *
49
+ productWithQty . quantity ,
47
50
0
48
51
) ;
49
52
return formatPrice ( total - promo + ( cart . shippingOption === 1 ? 5 : 15 ) , 2 ) ;
0 commit comments