diff --git a/client/src/modules/cart.ts b/client/src/modules/cart.ts index a35c2f5..50a443a 100644 --- a/client/src/modules/cart.ts +++ b/client/src/modules/cart.ts @@ -103,10 +103,13 @@ function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void { } function sumSeatPrices(): string { - let overallPrice: number = 0; + return config.state.selectedSeatsArr.map(getSeatPrice) + .reduce((prev, curr) => prev + curr) + .toFixed(2); +} - config.state.selectedSeatsArr.forEach(arr => { - const seatID: string = arr[0]; +function getSeatPrice(arr: string[]) { + const seatID: string = arr[0]; const buyertypeID: string = arr[1]; const selectedSeat: I.JSCSelectedSeat = config.state.selectedSeatsObj[seatID]; const pricescaleID: string = selectedSeat.data.seatsObj.id[0]; @@ -116,9 +119,8 @@ function sumSeatPrices(): string { const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj); if (seatPrice) - overallPrice += seatPrice; - } - }); + return seatPrice; + } - return overallPrice.toFixed(2); -} + return 0; +} \ No newline at end of file