@@ -60,17 +60,17 @@ export const getFormattedCart = (data) => {
60
60
61
61
let i = 0 ;
62
62
givenProducts . forEach ( ( ) => {
63
- const givenProduct = givenProducts [ parseInt ( i ) ] . product ;
63
+ const givenProduct = givenProducts [ parseInt ( i , 10 ) ] . product ;
64
64
const product = { } ;
65
65
// Convert price to a float value
66
- const convertedCurrency = givenProducts [ i ] . total . replace ( / [ ^ 0 - 9 . - ] + / g, '' ) ;
66
+ const convertedCurrency = givenProducts [ parseInt ( i , 10 ) ] . total . replace ( / [ ^ 0 - 9 . - ] + / g, '' ) ;
67
67
68
68
product . productId = givenProduct . productId ;
69
- product . cartKey = givenProducts [ i ] . key ;
69
+ product . cartKey = givenProducts [ parseInt ( i , 10 ) ] . key ;
70
70
product . name = givenProduct . name ;
71
- product . qty = givenProducts [ i ] . quantity ;
71
+ product . qty = givenProducts [ parseInt ( i , 10 ) ] . quantity ;
72
72
product . price = convertedCurrency / product . qty ;
73
- product . totalPrice = givenProducts [ i ] . total ;
73
+ product . totalPrice = givenProducts [ parseInt ( i , 10 ) ] . total ;
74
74
// Ensure we can add products without images to the cart
75
75
givenProduct . image
76
76
? ( product . image = {
@@ -84,7 +84,7 @@ export const getFormattedCart = (data) => {
84
84
title : givenProduct . name ,
85
85
} ) ;
86
86
87
- totalProductsCount += givenProducts [ i ] . quantity ;
87
+ totalProductsCount += givenProducts [ parseInt ( i , 10 ) ] . quantity ;
88
88
// Push each item into the products array.
89
89
formattedCart . products . push ( product ) ;
90
90
i ++ ;
0 commit comments