ACDiscountApp.PDPage.DisplayTiers = function () {
var storeTime = globalFields.Storetime();
// Parse the date string into individual components
let [currentYear, currentMonth, currentDay, currentHours, currentMinutes, currentSeconds] = storeTime.split(/[\sT:-]/);
currentYear = parseInt(currentYear);
currentMonth = parseInt(currentMonth); // Months are zero-based in JavaScript
currentDay = parseInt(currentDay);
currentHours = parseInt(currentHours);
currentMinutes =parseInt(currentMinutes);
currentSeconds = parseInt(currentSeconds);
function makeTimer(end_date) {
if(globalFields.isProduct_Page){
if(end_date != null){
jQuery("#ac_countDown").css("display", "block");
var endTime = end_date;
// Increment seconds by 1
currentSeconds++;
// Adjust minutes, hours, and day if necessary
if (currentSeconds >= 60) {
currentSeconds = 0;
currentMinutes++;
if (currentMinutes >= 60) {
currentMinutes = 0;
currentHours++;
if (currentHours >= 24) {
currentHours = 0;
currentDay++;
}
}
}
// Reformat the updated timestamp
let currentStoreTime = `${currentYear}-${currentMonth.toString().padStart(2, '0')}-${currentDay.toString().padStart(2, '0')}T${currentHours.toString().padStart(2, '0')}:${currentMinutes.toString().padStart(2, '0')}:${currentSeconds.toString().padStart(2, '0')}`;
endTime = (Date.parse(endTime) / 1000);
var now = currentStoreTime;
now = (Date.parse(now) / 1000);
var timeLeft = endTime - now;
var days = Math.floor(timeLeft / 86400);
var hours = Math.floor(timeLeft / 3600);
var exactHour = hours % 24;
var minutes = Math.floor((timeLeft - (hours * 3600 )) / 60);
var seconds = Math.floor((timeLeft - (hours * 3600) - (minutes * 60)));
var isDays = false;
if (days > 0 || hours > 24){isDays = true;}
if (days < 0) { days = "00"; /*hours = "0"; minutes = "0"; seconds = "0";*/ }
if (hours < 10) { hours = "0" + hours; }
if (minutes < 10) { minutes = "0" + minutes; }
if (seconds < 10) { seconds = "0" + seconds; }
if(timeLeft > 0){
if(isDays){
$(".ac__days").html(days); $(".ac__hours").html(exactHour); $(".ac__minutes").html(minutes);
$(".ac_sec, .ac__colon.seconds").hide();
}
else{
$(".ac__hours").html(exactHour); $(".ac__minutes").html(minutes); $(".ac__seconds").html(seconds);
$(".ac_day, .ac__colon.hours").hide(); $(".ac_sec, .ac__colon.seconds").show();
}
}
else{jQuery('.ac__settings__table, #ac_countDown').remove();}
setTimeout(function () {
jQuery('.ac__settings__table').after(jQuery("#ac_countDown"));
}, 500);
}
}
}
var hide_buttons = null;
var HideAdditionalPayments = function() {
hide_buttons = setInterval(function() {
if(jQuery('.shopify-payment-button__button').length>0){
jQuery('.shopify-payment-button__button').hide();
clearInterval(hide_buttons);
}
}, 500);
}
this.DisplayTiersFn = function () {
setTimeout(function () {
jQuery('.ac__settings__table').remove();
var selectedVariant = jQuery('input[name^=id]:checked, select[name^=id], input[name=id], hidden[name^=id]', jQuery('form[action="/cart/add"]')).val();
let ProductPage = globalFields.TableProductPage != undefined && globalFields.TableProductPage != '' ? globalFields.TableProductPage : 'true';
ProductPage = ProductPage == 'true' ? true: false;
if (selectedVariant != null && globalFieldsProductPage_AC.productMetafield != '[]' && globalFieldsProductPage_AC.productMetafield != undefined && ProductPage) {
let tierObj = globalFields.GetTierObject(globalFieldsProductPage_AC.productMetafield, selectedVariant);
let DiscountAppliedOn = tierObj.DiscountAppliedON != null && tierObj.DiscountAppliedON != '' && tierObj.DiscountAppliedON != undefined ? true : false;
let Location_Tag_s = tierObj.Location_Tag_ != null && tierObj.Location_Tag_ != '' && tierObj.Location_Tag_ != undefined ? true : false;
if(DiscountAppliedOn){
// 1
if(Location_Tag_s){
// 2
let DiscountAppliedOnTag = tierObj.DiscountAppliedON == 'Both_Store' || tierObj.DiscountAppliedON == 'Online_Store' ? true : false;
let LocationObject = Object.keys(tierObj.Location_Tag_);
if(LocationObject[0] == 'StoreLocation'){
let StoreLocationcheck = tierObj.Location_Tag_[LocationObject[0]].includes(globalFields.Storecountry) || tierObj.Location_Tag_[LocationObject[0]].includes(globalFields.Storecity) ? true : false;
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date) && DiscountAppliedOnTag && StoreLocationcheck) {
var getDates = globalFields.TimerStartEndDateValid(tierObj.start_date, tierObj.end_date);
getDates.valid; getDates.start_date; getDates.end_date;
let timer_settings = undefined;
WriteTableHeading(tierObj);
WriteTableRows(tierObj, selectedVariant);
if(timer_settings != undefined){
if(timer_settings.TimerStatus){
if(getDates.valid){
setInterval(function() { makeTimer(getDates.end_date); }, 1000);
}
}
}
jQuery('.shopify-payment-button__button').hide();
setTimeout(function(){
jQuery('.shopify-payment-button__button').hide();
HideAdditionalPayments();
}, 2000);
setTimeout(function(){
clearInterval(hide_buttons);
}, 5000);
}
}
else{
// 3
let TierLocation = tierObj.Location_Tag_[LocationObject[0]];
let CusotmerCountryLocation = globalFields.Customercountry;
let CusotmerCityLocation = globalFields.Customercity;
let CustomerLocationcheck_1 = (arr, arr1) =>{return arr.some(item => arr1.includes(item))};
let CustomerLocationcheck_2 = (arr2, arr3) =>{return arr2.some(item => arr3.includes(item))};
let CityValue = CustomerLocationcheck_1(TierLocation,CusotmerCountryLocation);
let CountryValue = CustomerLocationcheck_2(TierLocation,CusotmerCityLocation);
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date) && DiscountAppliedOnTag && (CityValue || CountryValue)) {
var getDates = globalFields.TimerStartEndDateValid(tierObj.start_date, tierObj.end_date);
getDates.valid; getDates.start_date; getDates.end_date;
let timer_settings = undefined;
WriteTableHeading(tierObj);
WriteTableRows(tierObj, selectedVariant);
if(timer_settings != undefined){
if(timer_settings.TimerStatus){
if(getDates.valid){
setInterval(function() { makeTimer(getDates.end_date); }, 1000);
}
}
}
jQuery('.shopify-payment-button__button').hide();
setTimeout(function(){
jQuery('.shopify-payment-button__button').hide();
HideAdditionalPayments();
}, 2000);
setTimeout(function(){
clearInterval(hide_buttons);
}, 5000);
}
}
}
else{
// 4
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date) && (tierObj.DiscountAppliedON == 'Both_Store' || tierObj.DiscountAppliedON == 'Online_Store')) {
var getDates = globalFields.TimerStartEndDateValid(tierObj.start_date, tierObj.end_date);
getDates.valid; getDates.start_date; getDates.end_date;
let timer_settings = undefined;
WriteTableHeading(tierObj);
WriteTableRows(tierObj, selectedVariant);
if(timer_settings != undefined){
if(timer_settings.TimerStatus){
if(getDates.valid){
setInterval(function() { makeTimer(getDates.end_date); }, 1000);
}
}
}
jQuery('.shopify-payment-button__button').hide();
setTimeout(function(){
jQuery('.shopify-payment-button__button').hide();
HideAdditionalPayments();
}, 2000);
setTimeout(function(){
clearInterval(hide_buttons);
}, 5000);
}
}
}
else{
// 5
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date)) {
var getDates = globalFields.TimerStartEndDateValid(tierObj.start_date, tierObj.end_date);
getDates.valid; getDates.start_date; getDates.end_date;
let timer_settings = undefined;
WriteTableHeading(tierObj);
WriteTableRows(tierObj, selectedVariant);
if(timer_settings != undefined){
if(timer_settings.TimerStatus){
if(getDates.valid){
setInterval(function() { makeTimer(getDates.end_date); }, 1000);
}
}
}
jQuery('.shopify-payment-button__button').hide();
setTimeout(function(){
jQuery('.shopify-payment-button__button').hide();
HideAdditionalPayments();
}, 2000);
setTimeout(function(){
clearInterval(hide_buttons);
}, 5000);
}
}
}
}, 200);
}
setTimeout(function(){
clearInterval(hide_buttons);
}, 10000);
this.OnVariantChange = function () {
setTimeout(function () {
$('.no-js-hidden fieldset[data-selector-type="listed"] .option-selector__btns label').click(function () {
displayTiers.DisplayTiersFn();
displayTiers.changePrice();
});
}, 2000);
}
this.OnVariantChangeIframe = function () {
var iframe = document.getElementById('cb-widget-frame');
if (iframe) {
try {
var iframeDocument = iframe != null ? iframe.contentDocument || iframe.contentWindow.document : false;
if (iframeDocument) {
var selectOption1 = iframeDocument.getElementById('id-select-option1');
var selectOption2 = iframeDocument.getElementById('id-select-option2');
var quantitychnage = iframeDocument.getElementsByClassName('stickyQuantityButton');
if (selectOption1) {
selectOption1.addEventListener('change', function() {
setTimeout(function () {
displayTiers.changePriceStickyHeader();
displayTiers.OnVariantChangeIframe();
}, 1000);
});
}
if(selectOption2){
selectOption2.addEventListener('change', function() {
setTimeout(function () {
displayTiers.changePriceStickyHeader();
displayTiers.OnVariantChangeIframe();
}, 1000);
});
}
if(quantitychnage){
quantitychnage[0].addEventListener('click', function() {
setTimeout(function () {
displayTiers.changePriceStickyHeader();
displayTiers.OnVariantChangeIframe();
}, 1000);
});
quantitychnage[1].addEventListener('click', function() {
setTimeout(function () {
displayTiers.changePriceStickyHeader();
displayTiers.OnVariantChangeIframe();
}, 1000);
});
}
} else {
console.error('Unable to access iframe document.');
}
} catch (error) {
console.error('Error accessing iframe content:', error);
}
iframe.onerror = function() {
console.error('Error loading the iframe.');
};
} else {
//console.error('Iframe element not found.');
}
}
var TableHeadHtml = function (contentHtml, tableSelector, position) {
jQuery(tableSelector).before(contentHtml)
}
var WriteTableHeading = function (tierObj) {
var tableSelector = 'form[action="/cart/add"] .btn.btn--large.add-to-cart';
if (globalFields.settings.selected_table == "table1") {
TableHeadHtml('
' + globalFields.settings.table_headers.header1_value + ' | ' + globalFields.settings.table_headers.header2_value + ' |
---|
', tableSelector);
}
if (globalFields.settings.selected_table == "table2") {
TableHeadHtml('' + globalFields.settings.table_headers.header1_value + ' | ' + globalFields.settings.table_headers.header2_value + ' | ' + globalFields.settings.table_headers.header3_value + ' |
---|
', tableSelector);
}
if (globalFields.settings.selected_table == "table3") {
TableHeadHtml('' + globalFields.settings.table_headers.header1_value + ' | ' + globalFields.settings.table_headers.header2_value + ' | ' + globalFields.settings.table_headers.header3_value + ' |
---|
', tableSelector);
}
if (globalFields.settings.selected_table == "table4") {
TableHeadHtml('', tableSelector);
}
}
var TableRowHtml = function (contentHtml, tableSelector) {
jQuery(tableSelector).append(contentHtml);
}
var TableRowSingle = function (tieredMin_, tieredMax_, discountedPrice, tieredOff,booleanmostPopularValues, index,tierObj,originalPrice_) {
var plusSign = tieredMin_ == tieredMax_ ? '' : '+', buyText = 'Buy ';
var priceHtml = '' + globalFields.formatMoney(discountedPrice, globalFields.amount) + '';
if (globalFields.settings.selected_table == "table1") {
if(booleanmostPopularValues){
TableRowHtml(' ' + tieredMin_ + plusSign + 'Most Popular'+ ' | ' + tieredOff + ' |
', '#ac_table1 .ac__tbody');
}else{
TableRowHtml(' ' + tieredMin_ + plusSign + ' | ' + tieredOff + ' |
', '#ac_table1 .ac__tbody');
}
}
if (globalFields.settings.selected_table == "table2") {
if(booleanmostPopularValues){
TableRowHtml(' ' + tieredMin_+ 'Most Popular' + ' | ' + tieredMax_ + ' | ' + tieredOff + ' |
', '#ac_table2 .ac__tbody');
}else{
TableRowHtml(' ' + tieredMin_ + ' | ' + tieredMax_ + ' | ' + tieredOff + ' |
', '#ac_table2 .ac__tbody');
}
}
if (globalFields.settings.selected_table == "table3") {
if(booleanmostPopularValues){
TableRowHtml(' ' + tieredMin_ + plusSign + 'Most Popular' + ' | ' + priceHtml + ' | ' + tieredOff + ' |
', '#ac_table3 .ac__tbody');
}else{
TableRowHtml(' ' + tieredMin_ + plusSign + ' | ' + priceHtml + ' | ' + tieredOff + ' |
', '#ac_table3 .ac__tbody');
}
}
if (globalFields.settings.selected_table == "table4") {
var quantityTextTable4 = tieredMin_ + "-" + tieredMax_;
if (tieredMax_ == "+") {
quantityTextTable4 = tieredMin_ + "+";
}
TableRowHtml(' ' + globalFields.settings.table_body.body1_value + ' ' + tieredMin_ + ' ' + globalFields.settings.table_body.body2_value + ' ' + tieredOff + ' |
', '#ac_table4');
}
}
this.changePrice = function(){ // change price when selectedVariant are changes
let currencySymbol_ = '£';
if(Shopify.currency.active == 'EUR'){ currencySymbol_ = '€'; }else if(Shopify.currency.active == 'USD'){ currencySymbol_ = '$'; }
var selectedVariantcheck = jQuery('input[name^=id]:checked, select[name^=id], input[name=id], hidden[name^=id]', jQuery('form[action="/cart/add"]')).val();
var originalChangeQty = jQuery('#quantity').val();
originalChangeQty = Number(originalChangeQty);
if(isNaN(originalChangeQty)){
originalChangeQty = 1;
}
var updatedItemPrice = 0
var selectedVariant = jQuery('input[name^=id]:checked, select[name^=id], input[name=id], hidden[name^=id]', jQuery('form[action="/cart/add"]')).val();
if(selectedVariant == ""){
let id_= Object.keys(globalFieldsProductPage_AC.variantsPriceArray_PD)
selectedVariant = id_[0];
}
var orignalPriceWithoutMoney = globalFields.priceChangeFunc(selectedVariantcheck);
var orignalPriceWithMoney = globalFields.formatMoney(orignalPriceWithoutMoney, globalFields.amount);
if (selectedVariant != null && globalFieldsProductPage_AC.productMetafield != '[]' && globalFieldsProductPage_AC.productMetafield != undefined && selectedVariant != "") {
var tierObj = globalFields.GetTierObject(globalFieldsProductPage_AC.productMetafield, selectedVariant);
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date)) {
for (i = 0; i < tierObj.tier_min.length; i++) {
var tierPrice = parseFloat(tierObj.tier_values[i]);
var minTier = parseInt(tierObj.tier_min[i]), maxTier = tierObj.tier_max[i] != 'max' ? parseInt(tierObj.tier_max[i]) : tierObj.tier_max[i];
var updatedLinePrice = 0, condition1 = false, condition2 = false;
var originalPrice_ = (Number(orignalPriceWithoutMoney) / 100);
condition1 = originalChangeQty >= minTier;
condition2 = maxTier == "max" || originalChangeQty <= maxTier;
if (condition1 && condition2) { break; }
}
if (condition1 && condition2) {
if (tierObj.discount_type == 'percentage') {
var originalPriceCut = parseFloat(globalFields.ConvertToFixedDecimalNumber((parseFloat(tierPrice) / 100) * globalFields.ConvertToFixedDecimalNumber(originalPrice_)));
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(globalFields.ConvertToFixedDecimalNumber(originalPrice_) - originalPriceCut);
}
else if (tierObj.discount_type == 'fixed') {
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(globalFields.ConvertToFixedDecimalNumber(originalPrice_) - parseFloat(tierPrice));
}
else if (tierObj.discount_type == 'fixed_price') {
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(parseFloat(tierPrice));
}
updatedItemPrice = globalFields.formatMoney(Number(updatedItemPrice).toFixed(2), globalFields.amount);
jQuery('.product-form.sticky-content-container .price__container .price__regular').replaceWith(`
${orignalPriceWithMoney} ${updatedItemPrice}
`)
}
else{
jQuery('.product-form.sticky-content-container .price__container .price__regular').replaceWith(`
${orignalPriceWithMoney}
`)
}
}
}
else{
jQuery('.product-form.sticky-content-container .price__container .price__regular').replaceWith(`
${orignalPriceWithMoney}
`)
}
}
this.changePriceStickyHeader = function(){ // change price when selectedVariant are not changes
let currencySymbol_ = '£';
if(Shopify.currency.active == 'EUR'){ currencySymbol_ = '€'; }else if(Shopify.currency.active == 'USD'){ currencySymbol_ = '$'; }
var selectedVariantcheck = jQuery('input[name^=id]:checked, select[name^=id], input[name=id], hidden[name^=id]', jQuery('form[action="/cart/add"]')).val();
var originalChangeQty = jQuery('#quantity').val();
originalChangeQty = Number(originalChangeQty);
if(isNaN(originalChangeQty)){
originalChangeQty = 1;
}
var updatedItemPrice = 0
var selectedVariant = jQuery('input[name^=id]:checked, select[name^=id], input[name=id], hidden[name^=id]', jQuery('form[action="/cart/add"]')).val();
if(selectedVariant == ""){
let id_= Object.keys(globalFieldsProductPage_AC.variantsPriceArray_PD)
selectedVariant = id_[0];
}
var orignalPricewithoutMoney = '';
var orignalPricewithMoney = '';
var iframe = document.getElementById('cb-widget-frame');
// Access the iframe's document
var iframeDocument = iframe != null ? iframe.contentDocument || iframe.contentWindow.document : false;
if(iframeDocument){
iframeDocument.querySelector('.stickyProductPriceOriginal').style.display = 'none';
// Access the span element inside the iframe
var priceValue = iframeDocument.getElementsByClassName('stickyProductPriceOriginal');
if (priceValue) {
priceValue = priceValue[0].innerText;
let numberString = priceValue.replace(/[\$,]/g, '');
let number = parseFloat(numberString);
orignalPricewithoutMoney = number;
orignalPricewithMoney = priceValue;
}
}
if (selectedVariant != null && orignalPricewithMoney != "" && globalFieldsProductPage_AC.productMetafield != '[]' && globalFieldsProductPage_AC.productMetafield != undefined && selectedVariant != "") {
var tierObj = globalFields.GetTierObject(globalFieldsProductPage_AC.productMetafield, selectedVariant);
if (tierObj != undefined && tierObj.status && globalFields.StartEndDateValid(tierObj.start_date, tierObj.end_date)) {
for (i = 0; i < tierObj.tier_min.length; i++) {
var tierPrice = parseFloat(tierObj.tier_values[i]);
var minTier = parseInt(tierObj.tier_min[i]), maxTier = tierObj.tier_max[i] != 'max' ? parseInt(tierObj.tier_max[i]) : tierObj.tier_max[i];
var updatedLinePrice = 0, condition1 = false, condition2 = false;
var originalPrice_ = (Number(orignalPricewithoutMoney));
condition1 = originalChangeQty >= minTier;
condition2 = maxTier == "max" || originalChangeQty <= maxTier;
if (condition1 && condition2) { break; }
}
if (condition1 && condition2) {
if (tierObj.discount_type == 'percentage') {
var originalPriceCut = parseFloat(globalFields.ConvertToFixedDecimalNumber((parseFloat(tierPrice) / 100) * globalFields.ConvertToFixedDecimalNumber(originalPrice_)));
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(globalFields.ConvertToFixedDecimalNumber(originalPrice_) - originalPriceCut);
}
else if (tierObj.discount_type == 'fixed') {
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(globalFields.ConvertToFixedDecimalNumber(originalPrice_) - parseFloat(tierPrice));
}
else if (tierObj.discount_type == 'fixed_price') {
updatedItemPrice = globalFields.ConvertToFixedDecimalNumber(parseFloat(tierPrice));
}
updatedItemPrice = globalFields.formatMoney(Number(updatedItemPrice).toFixed(2), globalFields.amount);
let element = iframeDocument.querySelector('.stickyProductPrice');
// Check if the element exists
if (element) {
// iframeDocument.querySelector('.anncodeItemPrice').remove();
let elementremove = iframeDocument.querySelector('.anncodeItemPrice');
// Check if the element exists and then remove it
if (elementremove !== null) {
elementremove.remove();
}
// Create a new span element
let newSpan = document.createElement('span');
newSpan.className = 'anncodeItemPrice money';
// Set the inner HTML of the new span element
newSpan.innerHTML = `${orignalPricewithMoney} ${updatedItemPrice}`;
// Append the new span to the selected element
element.appendChild(newSpan);
}
}
else{
// jQuery('.product-form.sticky-content-container .price__container .price__regular').replaceWith(`
//${orignalPriceWithMoney}
`)
}
}
}
else{
// jQuery('.product-form.sticky-content-container .price__container .price__regular').replaceWith(`
// ${orignalPriceWithMoney}
`)
}
}
// Function to be called when #cb-sticky width is 100%
function yourFunction() {
setTimeout(function () {
displayTiers.changePriceStickyHeader();
displayTiers.OnVariantChangeIframe();
}, 1000);
}
// Function to initialize the observer
function initializeObserver() {
// Check if the target element exists
const cbSticky = document.getElementById('cb-sticky');
if (!cbSticky) {
// If not, try again after a short delay
setTimeout(initializeObserver, 100);
return;
}
// Create a new ResizeObserver
const resizeObserver = new ResizeObserver(entries => {
for (const entry of entries) {
console.log("entry.contentRect.width",entry.target.id)
if (entry.target.id === 'cb-sticky') {
yourFunction();
}
}
});
// Start observing the #cb-sticky element
resizeObserver.observe(cbSticky);
}
// Call initializeObserver immediately
initializeObserver();
var WriteTableRows = function (tierObj, selectedVariant_) {
var originalPrice_ = globalFieldsProductPage_AC.variantsPriceArray_PD[selectedVariant_]; originalPrice_ = originalPrice_ / 100;
for (i = 0; i < tierObj.tier_min.length; i++) {
var isBreakLoop = false, tieredOff = Number(tierObj.tier_values[i]);
var tieredMin_ = parseInt(tierObj.tier_min[i]), tieredMax_ = tierObj.tier_max[i], discountedPrice = 0;
if (tieredMax_ != "max") {
tieredMax_ = parseInt(tieredMax_);
}
else {
tieredMax_ = "+";
}
if (tierObj.discount_type == "percentage") {
discountedPrice = Number(originalPrice_.toFixed(2));
var p = parseFloat(tieredOff) / 100, originalPriceCut_ = Number(parseFloat(p * discountedPrice).toFixed(2));
discountedPrice = discountedPrice - originalPriceCut_;
if (discountedPrice <= 0) {
discountedPrice = 0;
tieredOff = "100%";
isBreakLoop = true;
tieredMax_ = "+";
}
else {
discountedPrice = discountedPrice.toFixed(2);
tieredOff = tieredOff + "% OFF";
}
}
else if (tierObj.discount_type == "fixed_price") {
discountedPrice = tieredOff.toFixed(2);
tieredOff = globalFields.formatMoney(tieredOff.toFixed(2), globalFields.amount);
}
else {
discountedPrice = Number((originalPrice_ - tieredOff).toFixed(2));
if (discountedPrice <= 0) {
discountedPrice = 0;
tieredOff = globalFields.formatMoney(originalPrice_.toFixed(2), globalFields.amount);
isBreakLoop = true;
tieredMax_ = "+";
}
else {
discountedPrice = discountedPrice.toFixed(2);
tieredOff = globalFields.formatMoney(tieredOff.toFixed(2), globalFields.amount) + " OFF";
}
}
let booleanmostPopularValues = tierObj.mostPopularValues != undefined ? (tierObj.mostPopularValues[i] != undefined ? tierObj.mostPopularValues[i] : false) : false;
TableRowSingle(tieredMin_, tieredMax_, discountedPrice, tieredOff,booleanmostPopularValues, i + 1,tierObj,originalPrice_);
if (isBreakLoop) { break; }
}
}
}
var globalFieldsProductPage_AC = new ACDiscountApp.PDPage.Global(), displayTiers = new ACDiscountApp.PDPage.DisplayTiers();
displayTiers.DisplayTiersFn(); displayTiers.OnVariantChange();