fixed highest price by adding most expensive buyertypeid to state on seat select

This commit is contained in:
zino
2021-07-28 16:05:15 +02:00
parent 5d0c971d83
commit 6325183558
2 changed files with 8 additions and 5 deletions

View File

@@ -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;
}

View File

@@ -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