sorted buyer types in cart popup highest price first
This commit is contained in:
@@ -5,14 +5,14 @@ import * as Events from "./events";
|
|||||||
import * as CartButtons from "./cartButtons";
|
import * as CartButtons from "./cartButtons";
|
||||||
import Utils from "./utils";
|
import Utils from "./utils";
|
||||||
|
|
||||||
export function addItem(inSeatObj: I.JSCSelectedSeat): void {
|
export function addItem(inSeatObj: I.JSCSelectedSeat): void {
|
||||||
const color: string = `#${XMLHelper.getVenuePricescalePropertyByPricescaleID("color", inSeatObj.data.seatsObj.id[0])}`;
|
const color: string = `#${XMLHelper.getVenuePricescalePropertyByPricescaleID("color", inSeatObj.data.seatsObj.id[0])}`;
|
||||||
const category: string | undefined = Utils.encodeCP850DecodeUTF8( XMLHelper.getVenuePricescalePropertyByPricescaleID("desc", inSeatObj.data.seatsObj.id[0])! );
|
const category: string | undefined = Utils.encodeCP850DecodeUTF8(XMLHelper.getVenuePricescalePropertyByPricescaleID("desc", inSeatObj.data.seatsObj.id[0])!);
|
||||||
const seat: string = config.state.layoutRows[inSeatObj.id][5];
|
const seat: string = config.state.layoutRows[inSeatObj.id][5];
|
||||||
const row: string = config.state.layoutRows[inSeatObj.id][4];
|
const row: string = config.state.layoutRows[inSeatObj.id][4];
|
||||||
const sectionID: string = config.state.layoutRows[inSeatObj.id][3];
|
const sectionID: string = config.state.layoutRows[inSeatObj.id][3];
|
||||||
const sectionDesc: string | undefined = XMLHelper.getSectionDescBySectionID(sectionID);
|
const sectionDesc: string | undefined = XMLHelper.getSectionDescBySectionID(sectionID);
|
||||||
const seatStr: string | undefined = Utils.encodeCP850DecodeUTF8( `${sectionDesc}<br/>Reihe ${row} Platz ${seat}` );
|
const seatStr: string | undefined = Utils.encodeCP850DecodeUTF8(`${sectionDesc}<br/>Reihe ${row} Platz ${seat}`);
|
||||||
const buyerTypes: I.TypeBuyerType = XMLHelper.getBuyerTypesByPricescaleID(inSeatObj.data.seatsObj.id[0]);
|
const buyerTypes: I.TypeBuyerType = XMLHelper.getBuyerTypesByPricescaleID(inSeatObj.data.seatsObj.id[0]);
|
||||||
const cartID: string = `cartItem-${inSeatObj.id}`;
|
const cartID: string = `cartItem-${inSeatObj.id}`;
|
||||||
const dropdownBuyerTypesSelector: string = `#${cartID} .dropdownBuyerTypes`;
|
const dropdownBuyerTypesSelector: string = `#${cartID} .dropdownBuyerTypes`;
|
||||||
@@ -48,7 +48,7 @@ export function changedDropdownBuyerType(inSelect: HTMLSelectElement, inSeatObj:
|
|||||||
Events.addRedirectCheckout(url);
|
Events.addRedirectCheckout(url);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function calcOverallPrice(): void{
|
export function calcOverallPrice(): void {
|
||||||
if (!config.state.selectedSeatsArr.length)
|
if (!config.state.selectedSeatsArr.length)
|
||||||
config.state.priceOverall = "0";
|
config.state.priceOverall = "0";
|
||||||
else
|
else
|
||||||
@@ -113,20 +113,24 @@ function addDropdownBuyerTypeOptions(inBuyerTypes: I.TypeBuyerType, inSelector:
|
|||||||
if (!inBuyerTypes)
|
if (!inBuyerTypes)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
inBuyerTypes.forEach(arr => {
|
console.log(inBuyerTypes);
|
||||||
|
|
||||||
|
inBuyerTypes.sort((a, b) => {
|
||||||
|
return <any>b[1] - <any>a[1];
|
||||||
|
}).forEach(arr => {
|
||||||
if (arr[0])
|
if (arr[0])
|
||||||
appendOption(inSelector, arr)
|
appendOption(inSelector, arr)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void {
|
function appendOption(inSelector: string, inArr: I.TypeBuyerTypeArr): void {
|
||||||
const desc: string = Utils.encodeCP850DecodeUTF8( <string>inArr[2] );
|
const desc: string = Utils.encodeCP850DecodeUTF8(<string>inArr[2]);
|
||||||
const id: string = <string>inArr[0];
|
const id: string = <string>inArr[0];
|
||||||
const price: string = getPriceInEur(<string>inArr[1]);
|
const price: string = getPriceInEur(<string>inArr[1]);
|
||||||
const dropdownBuyerTypes: HTMLElement = jQuery(inSelector).get(0);
|
const dropdownBuyerTypes: HTMLElement = jQuery(inSelector).get(0);
|
||||||
|
|
||||||
console.log(price);
|
console.log(price);
|
||||||
|
|
||||||
let opt: HTMLOptionElement = document.createElement('option');
|
let opt: HTMLOptionElement = document.createElement('option');
|
||||||
opt.value = id;
|
opt.value = id;
|
||||||
opt.innerHTML = `${desc} ${price}`;
|
opt.innerHTML = `${desc} ${price}`;
|
||||||
@@ -141,17 +145,17 @@ function sumSeatPrices(): string {
|
|||||||
|
|
||||||
function getSeatPrice(arr: string[]) {
|
function getSeatPrice(arr: string[]) {
|
||||||
const seatID: string = arr[0];
|
const seatID: string = arr[0];
|
||||||
const buyertypeID: string = arr[1];
|
const buyertypeID: string = arr[1];
|
||||||
const selectedSeat: I.JSCSelectedSeat = config.state.selectedSeatsObj[seatID];
|
const selectedSeat: I.JSCSelectedSeat = config.state.selectedSeatsObj[seatID];
|
||||||
const pricescaleID: string = selectedSeat.data.seatsObj.id[0];
|
const pricescaleID: string = selectedSeat.data.seatsObj.id[0];
|
||||||
const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID);
|
const pricescaleObj: I.Pricescale5 | undefined = XMLHelper.getVenuePriceStructurePropertyByPricescaleID(pricescaleID);
|
||||||
|
|
||||||
if (pricescaleObj) {
|
if (pricescaleObj) {
|
||||||
const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj);
|
const seatPrice: number | undefined = XMLHelper.getPriceByBuyerTypeID(buyertypeID, pricescaleObj);
|
||||||
|
|
||||||
if (seatPrice)
|
if (seatPrice)
|
||||||
return seatPrice;
|
return seatPrice;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user