';
let loan_column_index = 1;
for (let loan_k in product.loanParameters) {
let current_loan = product.loanParameters[loan_k];
let current_loan_active = '';
if(current_loan.loanTerm == product.loanTerm) {
current_loan_active = ' comfino-active';
}
installments_html = installments_html + `
${current_loan.loanTerm}
`;
loan_column_index = loan_column_index + 1;
if(loan_column_index > 3) {
installments_html = installments_html + `
`;
loan_column_index = 1;
}
}
let txt_wybierz = 'Wybierz liczbę rat';
let txt_rata = 'Miesięczna rata:';
let txt_rrso = `
Łączna kwota do spłaty: ${toPay}
RRSO ${rrso} %
`;
if(product.type == 'COMPANY_BNPL') {
txt_wybierz = 'O ile dni chcesz odroczyć płatność?';
txt_rata = 'Łączna kwota do zapłaty:';
let wartosc_prowizji = product.toPay - product.instalmentAmount;
let txt_prowizja_operatora = formatter.format(wartosc_prowizji/100);
txt_rrso = `
Prowizja operatora: ${txt_prowizja_operatora}
`;
}
products_html = products_html + `
${txt_wybierz}
${installments_html}
${txt_rata}
${instalmentAmount}
${txt_rrso}
${product.description}
`;
if(product.representativeExample.length > 0) {
footer_html = footer_html + `
`;
}
}
}
$('.mx_comfino_preloader').slideUp(0);
$('label[for="payment_' + config.payment_id + '"]').last().parent().parent().append(`
Wartość zakupów:
${amount}
${products_html}
${footer_html}
`);
$('body').append($(''))
$('.comfino').slideDown(0);
// wybór liczby rat
$('.comfino-installments-quantity').click(function() {
let type = $(this).data('type');
let instalmentAmount = $(this).data('instalmentamount');
let loanTerm = $(this).data('loanterm');
let toPay = $(this).data('topay');
let rrso = $(this).data('rrso');
$(`.comfino-variant-${type} .comfino-installments-quantity`).removeClass('comfino-active');
$(this).addClass('comfino-active');
if(type == 'COMPANY_BNPL') {
let kwota_oryginalna = toPay;
toPay = toPay - instalmentAmount;
instalmentAmount = kwota_oryginalna;
}
toPay = formatter.format(toPay/100);
instalmentAmount = formatter.format(instalmentAmount/100);
rrso = (rrso * 100).toFixed(2) + ' %';
$(`.comfino-variant-${type} .comfino-monthly-rate`).text(instalmentAmount);
$(`.comfino-variant-${type} .comfino-summary-total span`).text(toPay);
$(`.comfino-variant-${type} .comfino-rrso span`).text(rrso);
window.localStorage.setItem('mx_comfino_chosen_product',`${type}||${loanTerm}`);
// console.log(`${type}||${loanTerm}`);
});
//END wybór liczby rat
// popup przykład reprezentatywny
$('.comfino-footer-link').click(function() {
$('.mx_comfino_popup_all').fadeIn(150);
let type = $(this).data('type');
$('.mx_comfino_popup_content').html($(`#representative-example-${type}`).val());
});
$('.mx_comfino_popup_close').click(function() {
$('.mx_comfino_popup_all').fadeOut(150);
});
//END popup przykład reprezentatywny
// odświeżanie widgetu po zmianie wyboru produktu finansowego
let mxRefreshComfinoBox = function() {
$('.comfino-variant').slideUp(0);
let current_variant = $('.comfino-variant-'+$('.comfino-input:checked').data('type'));
current_variant.slideDown(0);
if(current_variant.find('.comfino-installments-quantity.comfino-active').length > 0) {
current_variant.find('.comfino-installments-quantity.comfino-active').click();
}
else {
window.localStorage.setItem('mx_comfino_chosen_product',$('.comfino-input:checked').data('type') + '||');
// console.log($('.comfino-input:checked').data('type') + '||');
}
};
mxRefreshComfinoBox();
$('.comfino-input').change(function() {
mxRefreshComfinoBox();
});
};
let loadTimeout = setTimeout(() => {
mxInitComfinoBasket(logo_in_form,config);
}, 100);
// początkowe załadowanie formularza:
// mxInitComfinoBasket(logo_in_form,config);
// odświeżani formularza po zmianie płatności/dostawy
$('.payment input[type="radio"]').change(function() {
if($(this).hasClass('comfino-input')) {
return true;
}
clearTimeout(loadTimeout);
loadTimeout = setTimeout(() => {
mxInitComfinoBasket(logo_in_form,config);
}, 100);
});
$('.delivery input[type="radio"]').change(function() {
if($(this).hasClass('comfino-input')) {
return true;
}
clearTimeout(loadTimeout);
loadTimeout = setTimeout(() => {
mxInitComfinoBasket(logo_in_form,config);
}, 100);
});
//END odświeżani formularza po zmianie płatności/dostawy
let css = `
.comfino {
max-width: 700px;
margin: 7px auto;
border: 1px solid #e7e7e7;
padding: 14px;
border-radius: 14px;
}
.comfino * {
outline: none;
-webkit-tap-highlight-color: transparent;
}
.comfino-box {}
.comfino-header {
display: flex;
flex-direction: column;
}
.comfino-logo {
margin: 0 auto;
}
.comfino-title {
text-align: center;
font-weight: bold;
font-size: 1.2rem;
margin: 0.875rem 0;
}
.comfino-select-payment {}
.comfino-single-payment {
border-bottom: 1px solid #ddd;
display: flex;
align-items: center;
}
.comfino-single-payment label {
display: flex;
align-items: center;
width: 100%;
}
.comfino-single-payment__text {
padding-left: 5px;
}
.comfino-single-payment input {
width: 25px;
height: 25px;
}
.comfino-input[type="radio"]:checked, .comfino-input[type="radio"]:not(:checked) {
position: absolute;
left: -9999px;
}
.comfino-input[type="radio"]:checked+label, .comfino-input[type="radio"]:not(:checked)+label {
position: relative;
padding-left: 28px;
cursor: pointer;
line-height: 20px;
/* display: flex; */
color: #666;
}
.comfino-input[type="radio"]:checked+label:before, .comfino-input[type="radio"]:not(:checked)+label:before {
content: '';
position: absolute;
left: 0;
/* top: 0; */
width: 18px;
height: 18px;
border: 2px solid #ddd;
border-radius: 100%;
background: #fff;
}
.comfino-input[type="radio"]:checked+label:after, .comfino-input[type="radio"]:not(:checked)+label:after {
content: '';
width: 8px;
height: 8px;
background: #599e33;
;
position: absolute;
/* top: 4px; */
left: 7px;
border-radius: 100%;
-webkit-transition: all 0.2s ease;
transition: all 0.2s ease;
}
.comfino-input[type="radio"]:not(:checked)+label:after {
opacity: 0;
-webkit-transform: scale(0);
transform: scale(0);
}
.comfino-input[type="radio"]:checked+label:after {
opacity: 1;
-webkit-transform: scale(1);
transform: scale(1);
}
.comfino-payment-box {
background-color: rgb(221, 221, 221);
display: flex;
flex-direction: column;
align-items: center;
padding: 1rem 0;
font-size: 1.2rem;
margin-top: 1rem;
}
.comfino-payment-title {
color: #666;
margin-bottom: 7px;
}
.comfino-total-payment {
font-weight: bold;
}
.comfino-payment-delay {
padding: 1rem;
}
.comfino-payment-delay__title {
text-align: center;
font-weight: bold;
font-size: 1.2rem;
}
.comfino-payment-delay__title span {
display: block;
color: #599e33;
padding: .3rem 0;
}
.comfino-payment-delay__box {
display: flex;
align-items: center;
justify-content: center;
flex-wrap: wrap;
}
.comfino-helper-box {
display: flex;
margin-top: 10px;
}
.comfino-payment-delay__single-instruction {
width: 140px;
margin: 10px;
display: flex;
flex-direction: column;
align-items: center;
}
.comfino-single-instruction__text {
text-align: center;
font-size: .9rem;
padding-top: 1rem;
color: #666;
}
.comfino-single-instruction-img__background {
width: 50px;
height: 50px;
background-color: #599e33;
border-radius: 50%;
display: flex;
align-items: center;
justify-content: center;
padding: .5rem;
}
.comfino-single-instruction-img {
width: 100px;
filter: invert(100%)
}
.comfino-total-payment {
font-weight: bold;
}
.comfino-installments-box {
display: flex;
flex-direction: column;
}
.comfino-installments-title {
font-size: 1.2rem;
font-weight: bold;
text-align: center;
padding: 20px 0;
}
.comfino-quantity-select {
display: flex;
align-items: center;
flex-wrap: wrap;
max-width: 90%;
justify-content: center;
margin: 0 auto;
}
.comfino-select-box {
display: flex;
}
.comfino-installments-quantity {
width: 50px;
height: 50px;
border-radius: 50%;
background-color: rgb(221, 221, 221);
display: flex;
align-items: center;
justify-content: center;
color: #fff;
font-size: 1.4rem;
margin: 10px 20px;
cursor: pointer;
}
@media screen and (max-width: 980px) {
.comfino-installments-quantity {
margin: 5px 10px;
}
}
.comfino-active {
background-color: #599e33;;
}
.comfino-monthly-box {
background-color: #599e33;;
display: flex;
flex-direction: column;
align-items: center;
padding: 1rem 0;
font-size: 1.2rem;
color: #fff;
margin-top: 1rem;
}
.comfino-monthly-title {
font-size: 1.2rem;
text-align: center;
margin-bottom: 7px;
}
.comfino-monthly-rate {
font-weight: bold;
}
.comfino-max_wrap { height: 7px; }
.comfino-summary-box {
text-align: center;
font-size: .8rem;
color: gray;
}
.comfino-summary-total {
padding: .5rem 0;
}
.comfino-rrso {}
.comfino-footer-link {
display: block;
text-align: center;
padding: .5rem 0;
color: gray;
font-size: .7rem;
margin: 7px 0;
text-decoration: underline;
cursor: pointer;
}
.comfino-footer-link:hover {
opacity: 0.9;
}
.mx_comfino_popup_mask {
position: fixed;
left: 0;
top: 0;
background: rgba(0,0,0,0.2);
z-index: 100;
width: 100%;
height: 100%;
display: grid;
justify-content: center;
align-items: center;
place-items: center;
}
.mx_comfino_popup {
background-color: #fff;
border-radius: 20px;
padding: 40px;
font-size: 13px;
color: #6d6d6d;
position: relative;
width: 80%;
min-width: 260px;
}
.mx_comfino_popup_close {
position: absolute;
top: 20px;
right: 20px;
font-size: 37px;
font-weight: bold;
cursor: pointer;
}
.mx_comfino_popup_close:hover{
opacity: 0.9;
}`;
let style = document.createElement('style');
if (style.styleSheet) {
style.styleSheet.cssText = css;
} else {
style.appendChild(document.createTextNode(css));
}
document.getElementsByTagName('head')[0].appendChild(style);
}
//END KOSZYK
};
// init aplikacji po załadowaniu frontApi
let fApiWait = function() {
if(!window.frontAPI) {
setTimeout(fApiWait,1);
return;
}
mxComfinoInit();
}
fApiWait();
//END init
});