function SMShipMethods(){ var SMPrice = new cSMPrice(), totalPrice = 0, usingShipToAddress = false; SMPrice.decode(SMShop.basket.getAttribute(_SMADSubTotal)); this.relTotalPrice = SMShop.getAttribute(_SMAInGross)!="1" ? SMPrice.net : SMPrice.gross; /* find country */ usingShipToAddress = (SMShop.getFormElement("BILLTO", "BILLTO_SHIPTO_DIFFERS") != null); if(usingShipToAddress){ usingShipToAddress = cbool(SMShop.getFormValue("BILLTO", "BILLTO_SHIPTO_DIFFERS", true)); }; if(usingShipToAddress){ this.relCountryCode = SMShop.getFormValue('SHIPTO','SHIPTO_COUNTRY', true).toUpperCase(); }else{ this.relCountryCode = SMShop.getFormValue('BILLTO','BILLTO_COUNTRY', true).toUpperCase(); }; /* continue */ this.relTotalWeight = SMShop.basket.getAttribute(_SMAWeightTotal); this.relTotalQty = SMShop.basket.getAttribute(_SMATotalItems); this.relSelectedItemId = SMShop.getActiveShipMethodId(); this.getSelectedShipMethod = SMShipMethods_getSelectedShipMethod; this.setShipMethod = SMShipMethods_setShipMethod; this.saveRedirect = SMShipMethods_saveRedirect; this.calcDynamic = SMShipMethods_calcDynamic; this.calcCharge = SMShipMethods_calcCharge; this.autoSelect = SMShipMethods_autoSelect; this.saveMethod = SMShipMethods_saveMethod; this.printTable = SMShipMethods_printTable; this.htmlTable = SMShipMethods_htmlTable; this.goBack = SMShipMethods_goBack; this.selectdItemIndex = 0; this.arrMethods = function(){ var sWeight = '', fromWeight = maxWeight = 0, arrWeight = null; var dblCharge = 0, arrSource = null, arrTarget = new Array(); var oCalculator = oMethod = null, sPluginRef = sPluginFunction = ''; for(pkid in m_arrShipMethods){ if(isNaN(pkid)) continue; arrSource = m_arrShipMethods[pkid].split(';'); oMethod = new SMShipMethod(); oMethod.id = SX_uEsc(arrSource[0]); oMethod.name = SX_uEsc(arrSource[1]); oMethod.desc = SX_uEsc(arrSource[2]); oMethod.thumb = SX_uEsc(arrSource[3]); oMethod.exclPayMethods = arrSource[9]; oMethod.publicId = SX_uEsc(arrSource[10]); oCalculator = new SMShipCalculator(pkid, arrSource[8], this.relCountryCode); // zones if(oCalculator == null || oCalculator.chargeValues == null) continue; oMethod.calculator = oCalculator; oMethod.calcShipSurcharge = false; sPluginRef = arrSource[4].toString(); // pluginref if(sPluginRef.length > 0){ sPluginFunction = 'SMShipMethodPlugin_' + SX_uEsc(sPluginRef); try{window[sPluginFunction](oMethod)} catch(e){continue}; }; sWeight = arrSource[7].toString(); // fromWeight, maxWeight if(sWeight.length > 0){ arrWeight = sWeight.split(','); fromWeight = parseFloat(arrWeight[0]); maxWeight = parseFloat(arrWeight[1]); if(this.relTotalWeight < fromWeight || (maxWeight > 0 && this.relTotalWeight > fromWeight && this.relTotalWeight > maxWeight)) continue; }; dblCharge = this.calcCharge(oCalculator); if(dblCharge < 0) continue; oMethod.charge = parseFloat(dblCharge); oMethod.taxkey = parseInt(arrSource[5]); if(parseInt(arrSource[6]) == 1){ // calcProductSurcharges oMethod.calcShipSurcharge = true; }; if(oMethod.id == this.relSelectedItemId){ this.selectdItemIndex = parseInt(arrTarget.length); }; arrTarget[arrTarget.length] = oMethod; }; return(arrTarget); }; this.shipMethods = this.arrMethods(); this.selectedMethod = null; this.doAutoSelect = false; }; function SMShipMethod(){ this.id = ''; this.publicId = ''; this.name = ''; this.desc = ''; this.thumb = ''; this.charge = 0; this.taxkey = 0; this.exclPayMethods = ''; this.calculator = null; }; function SMShipMethods_setShipMethod(shipMethodId){ this.selectedMethod = null; for(var i=0;i 0 && dblCharge > calculator.chargeMax){ dblCharge = calculator.chargeMax; }; }; return(dblCharge); }; function SMShipMethods_calcCharge(calculator){ var oCalc = null, bytBase = 0, bCalculate = false; if(calculator.chargeFreeFrom > 0 && this.relTotalPrice >= calculator.chargeFreeFrom){ return(0); // charge free } else if(calculator.chargeType == 0){ // fix return(calculator.chargeValue); } else if(calculator.chargeType == 1){ // dynamic return(this.calcDynamic(calculator,false)); } else if(calculator.shipTables != null){ // table bytBase = calculator.chargeBase; for(var i=0;i0 ? zones.split(',') : null; if(arrZones == null){ if(m_arrShipCalculators[pkid]){ return(m_arrShipCalculators[pkid].split(';')); }; } else { for(var i=0; i -1){ return(m_arrZoneCalculators[arrZones[i]].split(';')); }; }; }; }; this.chargeValues = arrCharge(); if(this.chargeValues != null){ this.chargeType = parseInt(this.chargeValues[0]); this.chargeBase = parseInt(this.chargeValues[1]); this.chargeValue = parseFloat(this.chargeValues[2]); this.chargeMultiplier = parseFloat(this.chargeValues[3]); this.chargeMax = parseFloat(this.chargeValues[4]); this.chargeFreeFrom = parseFloat(this.chargeValues[5]); this.shipTables = null; if(this.chargeType == 2){ this.shipTables = new SMShipTables(this.chargeValues).tables; }; }; }; function SMShipTables(cvalues){ var arrTables = function(){ var arrTable = cvalues[6].length>0 ? cvalues[6].split(',') : null; var arrValues = new Array(); if(arrTable!=null){ for(var i=0;i 0){ for(var i=0;i 0){ sProductSurcharges = cprimary.format((SMShop.getAttribute(_SMAOutGross)!="1") ? oSMPriceSurcharge.net : oSMPriceSurcharge.gross, SM_CGROUP + SM_CSYMBOL); sProductSurchargesCaption = sProductSurchargesCaption.replace(/%su/gi, sProductSurcharges); } else { sProductSurcharges = ''; sProductSurchargesCaption = ''; }; sTable += '' + '' + ''; if(arrMethods[i].thumb.length > 0){ imgThumb = new Image(); imgThumb.src = arrMethods[i].thumb; sTable += ''; }; sTable += '

' + arrMethods[i].desc; if(sProductSurchargesCaption != ''){ sTable += '
' + sProductSurchargesCaption; }; sTable += '
' + '' + '' + cprimary.format(cbool(SMShop.getAttribute(_SMAOutGross)) ? oSMPrice.gross : oSMPrice.net, SM_CGROUP + SM_CSYMBOL); + '' + ''; }; sTable += ''; sTable += ' '; sTable += ''; } else { sTable += 'Verzeihung. Das System konnte leider keine entsprechende Versandart bereitstellen. Bitte kontaktieren Sie uns, um Ihnen ein Angebot zu machen.' + ''; }; sTable += ''; return(sTable); }; function SMShipMethods_printTable(){ document.write(this.htmlTable()); }; function SMShipMethods_saveMethod(selectedMethodId){ if(this.setShipMethod(selectedMethodId)){ return(SMShop.setShipMethod(this.selectedMethod)); }; return(false); }; function SMShipMethods_saveRedirect(){ if(this.saveMethod(this.getSelectedShipMethod())){ location.href = SMGetCheckoutStep('SM_RESERVED_DATA_ENTRY_SHIPMENT', false); }; return(false); }; function SMShipMethods_goBack(){ location.href = SMGetCheckoutStep('SM_RESERVED_DATA_ENTRY_SHIPMENT', true); return(false); }; function SMShipMethods_getSelectedShipMethod(){ var elem = null; for(var i=0;i