' + imagifyPricingModal.labels.errorPriceAPI + '
');
// Show the modal content.
imagifyModal.$modal.find('.imagify-modal-loader').fadeOut(300);
imagifyModal.$modal.removeClass('imagify-modal-loading');
return;
}
// Autofill coupon code & Show banner if discount is active.
w.imagify_discount_datas = promo_datas;
if (promo_datas.is_active) {
if (promo_datas.applies_to instanceof Array) {
plan_names = [];
var plan_list = [];
for (var plan_infos = 0; plan_infos < promo_datas.applies_to.length; plan_infos++) {
plan_list.push(promo_datas.applies_to[plan_infos].plan_name);
}
plan_list.forEach(function (item) {
if (! plan_names.includes(item)) {
plan_names.push(item);
}
});
plan_names = plan_names.join(', ');
} else {
plan_names = promo_datas.applies_to;
}
$banners = $('.imagify-modal-promotion');
date_end = promo_datas.date_end.split('T')[0];
promo = promo_datas.coupon_value;
discount = 'percentage' === promo_datas.coupon_type ? promo + '%' : '$' + promo;
// Show banners.
$banners.addClass('active').attr('aria-hidden', 'false');
// Populate banners.
$banners.find('.imagify-promotion-number').text(discount);
$banners.find('.imagify-promotion-plan-name').text(plan_names);
$banners.find('.imagify-promotion-date').text(date_end);
}
/**
* Below lines will build Plan and Onetime offers lists.
* It will also pre-select a Plan and/or Onetime in both of views: pre-checkout and pricing tables.
*/
if (0 === offers.mo.length) {
$('.imagify-pre-checkout-offers .imagify-offer-monthly').remove();
$('.imagify-tabs').remove();
$('.imagify-pricing-tab-monthly').remove();
} else {
// Now, do the MONTHLIES Markup.
offers.mo = offers.mo.reverse();
$.each(offers.mo, function (index, value) {
var $tpl,
classes = '';
// Populate each offer.
$tpl = $(mo_clone).clone();
$tpl = imagifyModal.populateOffer($tpl, value, 'monthly', classes);
// Complete Monthlies HTML.
mo_html += $tpl[0].outerHTML;
});
// Wait for element to be ready after ajax callback before adding ribbon.
setTimeout(function() {
// Add best value ribbon to unlimited plan.
$('.imagify-best-value').prepend('