diff --git a/client/src/modules/cart.ts b/client/src/modules/cart.ts index c894a99..1491e24 100644 --- a/client/src/modules/cart.ts +++ b/client/src/modules/cart.ts @@ -20,7 +20,7 @@ export function addItem(inSeatObj: I.JSCSelectedSeat): void { appendHTML(cartID, color, category, seatStr); addDropdownBuyerTypeOptions(buyerTypes, dropdownBuyerTypesSelector); Events.addCartDropdownBuyerTypes(dropdownBuyerTypesSelector, inSeatObj); - jQuery(".dropdownBuyerTypes").trigger("change"); // refresh cart because of highest buyer type sort + //jQuery(".dropdownBuyerTypes").trigger("change"); // refresh cart because of highest buyer type sort => we dont need this because we add mostExpensiveBuyerTypeID now } export function removeCartItems(): void { @@ -143,7 +143,6 @@ function getSeatPrice(arr: string[]) { if (pricescaleObj) { const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj); - if (seatPrice) return seatPrice; } diff --git a/client/src/modules/state.ts b/client/src/modules/state.ts index cf45bca..ef9ceaf 100644 --- a/client/src/modules/state.ts +++ b/client/src/modules/state.ts @@ -9,9 +9,13 @@ export function addSeatToState(inSelectedSeat: I.JSCSelectedSeat): void { const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID); if (pricescaleObj) { - const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; - const buyerTypeCode: string | undefined = XMLHelper.getBuyerTypeCodeByBuyerTypeID(firstBuyerTypeID); - const selectedSeatsArrItem: (string | undefined)[] = [inSelectedSeat.id, firstBuyerTypeID, buyerTypeCode]; + //const firstBuyerTypeID: string = pricescaleObj.buyer_type[0].id[0]; // needs to be highest amount + const mostExpensiveBuyerTypeID: string = pricescaleObj.buyer_type.reduce((prev, current) => { + return (prev.price[0] > current.price[0]) ? prev : current + }).id[0] + + const buyerTypeCode: string | undefined = XMLHelper.getBuyerTypeCodeByBuyerTypeID(mostExpensiveBuyerTypeID); + const selectedSeatsArrItem: (string | undefined)[] = [inSelectedSeat.id, mostExpensiveBuyerTypeID, buyerTypeCode]; addSeatsItemToState(selectedSeatsArrItem); } else