/** * NOTICE OF LICENSE * * This file is licenced under the Software License Agreement. * With the purchase or the installation of the software in your application * you accept the licence agreement. * * You must not modify, adapt or create derivative works of this source code * * @author PrestaHelp.com * @copyright 2019-2022 PrestaHelp * @license LICENSE.txt */ $(document).ready(function () { if (typeof checkoutInpost == 'undefined') { checkoutInpost = 'default'; } if (typeof showWeek == 'undefined') { showWeek = 0; } if (checkoutInpost == 'ets_onepagecheckout') { setTimeout(function() { initInpost($('.delivery-options-list .delivery-option input:checked')); }, 500); $(document).on('click', '.delivery-options-list .delivery-option input', function() { initInpost($(this)); }); $(document).on('click', '.ec-order-btn', function() { inpostCGVspStepCheckout($("#conditions_to_approve")); }); $(document).on('click', '#conditions_to_approve', function() { inpostCGVspStepCheckout($("#conditions_to_approve")) }) } if (checkoutInpost == 'steasycheckout') { $('.steco-custom-input').on('click', function(e) { inpostBindRadio($(this), e); }); prestashop.on('steco_init', function () { setTimeout(function() { $('.steco-custom-input-box.steco-tick').each(function(){ var ch = $(this).find('i.checkbox-checked'); if (ch.is(':visible')) { id = parseInt(ch.parent().prev().val()); elem = ch.parent().prev(); } }); initInpost(elem); }, 2500); }) prestashop.on('steco_event_init', function () { setTimeout(function() { $('.steco-custom-input-box.steco-tick').each(function(){ var ch = $(this).find('i.checkbox-checked'); if (ch.is(':visible')) { id = parseInt(ch.parent().prev().val()); elem = ch.parent().prev(); } }); initInpost(elem); }, 2500); }) prestashop.on( 'updatedDeliveryForm', function() { setTimeout(function() { $('.steco-custom-input-box.steco-tick').each(function(){ var ch = $(this).find('i.checkbox-checked'); if (ch.is(':visible')) { id = parseInt(ch.parent().prev().val()); elem = ch.parent().prev(); } }); initInpost(elem); }, 1000); } ); $(document).on("click", "#steco-conditions-to-approve .steco-custom-input" , function() { inpostCGV(); }); } if (checkoutInpost == 'supercheckout') { if ($("#conditions_to_approve[terms-and-conditions]").length) { $("#conditions_to_approve[terms-and-conditions]").unbind('click', inpostCGV).bind('click', inpostCGV); } $('#supercheckout-agree input').on('click', function() { inpostCGV(); }); var elem; setTimeout(function() { $('.delivery_option_radio').each(function(){ var ch = $(this); if (ch.is(':checked')) { id = parseInt(ch.val()); elem = ch; } }); initInpost(elem); }, 2500); } if (checkoutInpost == 'default') { $("button.standard-checkout").unbind('click', inpostCGV).bind('click', inpostCGV); $("button.continue").unbind('click', inpostCGV).bind('click', inpostCGV); $('#checkout-payment-step h1').unbind('click', inpostCGV).bind('click', inpostCGV); $('.delivery-option input').on('click', function (e) { inpostBindRadio($(this), e); }); initInpost($('.delivery-option input' + ":checked")); if (showWeek == 0) { $('.delivery-option').each(function() { var idd = parseInt($(this).find('input').val()); if (inpostkey_week.indexOf(idd) > -1 || inpostkey_week_cod.indexOf(idd) > -1) { $(this).hide(); } }); } } if (checkoutInpost == 'spstepcheckout') { setTimeout(function() { $('.delivery-option').each(function(){ var ch = $(this).find('input.delivery_option_radio'); if (ch.is(':checked')) { id = parseInt(ch.val()); elem = ch; } }); initInpost(elem); }, 2500); } $('.delivery-options-list button').on('click', function(){ var val = $('.tr-inpost-box .inpostship-main .inpost-point').val(); if (val == '' && selectedPointInfo == '') { $('#inpostshipmodal').modal(); $('#cgv').parent().removeClass('checked'); return false; } }); $('#inpostshipmodal .modal-footer button').on('click', function() { $('#inpostshipmodal').modal('hide'); }); $('#inpostshipmodal .modal-header button').on('click', function() { $('#inpostshipmodal').modal('hide'); }); $(document).on('click', '#inpostshipmodal .modal-footer button', function() { $('#inpostshipmodal').modal('hide'); }); $(document).on('click', '#inpostshipmodal .modal-header button', function() { $('#inpostshipmodal').modal('hide'); }); }); var assetsServer = 'https://api-pl-points.easypack24.net/v1'; function openModalMap(id) { $('#easypack-widget').empty(); $('#easypack-map').empty(); var pointType = ['parcel_locker_only']; if (pTypes == 1) { pointType = ['parcel_locker', 'pop']; } if (mapBox == 1) { if (imap == 'google') { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, googleKey: imgm }, }); } else { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, }, }); } if (imw == 1) { var width = 500; var height = ($(window).height() * 0.7); // 600 } else { var width = $(window).width() - 25; var height = ($(window).height() -25); // 600 } if (mapShow == 2) { width = ($(window).width() * 0.7); } easyPack.modalMap(function (point, modal) { updateInpostInfo(cart, id, point.name); modal.closeModal(); return false; }, {width: width, height: height}); } else { if (imap == 'google') { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, googleKey: imgm }, }); } else { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, }, }); } easyPack.mapWidget('easypack-widget', function(point) { updateInpostInfo(cart, id, point.name); }); } } function openModalMapCod(id) { $('#easypack-widget').empty(); $('#easypack-map').empty(); var pointType = ['parcel_locker']; if (pTypes == 1) { pointType = ['parcel_locker', 'pop']; } if (mapBox == 1) { if (imap == 'google') { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, googleKey: imgm }, paymentFilter: { visible: true, showOnlyWithPayment: true, } }); } else { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, }, paymentFilter: { visible: false, showOnlyWithPayment: true, } }); } var width = 500; var height = ($(window).height() * 0.7); // 600 if (mapShow == 2) { width = ($(window).width() * 0.7); } easyPack.modalMap(function (point, modal) { updateInpostInfo(cart, id, point.name); modal.closeModal(); return false; }, {width: width, height: height}); } else { if (imap == 'google') { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, googleKey: imgm }, paymentFilter: { visible: true, showOnlyWithPayment: true, } }); } else { easyPack.init({ instance: 'pl', defaultLocale: 'pl', points: { types: pointType }, locales: 'pl', apiEndpoint: assetsServer, mapType: imap, searchType: imap, map: { useGeolocation: true, initialTypes: pointType, }, paymentFilter: { visible: true, showOnlyWithPayment: true, } }); } easyPack.mapWidget('easypack-widget', function(point) { updateInpostInfo(cart, id, point.name); }); } } function inpostCGVUncheck() { $("#cgv").prop('checked', false); if (typeof $.uniform != 'undefined') { $.uniform.update(); } } function inpostBindRadio(el, e) { inpostCGVUncheck(); initInpost(el, true); } function updateInpostInfo(id_cart, id_carrier, point) { $('.saveInfo').remove(); var ile = 9; if (point.indexOf('POP') > -1) { ile = 12; } if (point.length < ile) { $('.tr-inpost-box .inpostship-main').css({ 'border': '1px solid #999' }); $('.point-info').remove(); var week = 0; if ($('.weekPack').is(':checked')){ week = 1; } $.ajax({ type: 'POST', headers: {"cache-control": "no-cache"}, url: baseDirShop + 'modules/inpostship/setPoint.php', async: false, cache: false, dataType: 'json', data: 'id_cart=' + id_cart + '&id_carrier=' + id_carrier + '&point=' + point + '&week='+week, success: function (jsonData) { $('.saveInfo').remove(); if (jsonData === false) { $('.tr-inpost-box .inpostship-main').css({ 'border': '3px solid #ff0000' }); $('.tr-inpost-box .inpostship-main').append('Paczkomat nie został poprawnie zapisany'); } else { $('.tr-inpost-box .inpostship-main').css({ 'border': '3px solid #67A901' }); $('.tr-inpost-box .inpostship-main').append('

Wybrany paczkomat:
' + jsonData.point_code + ', ul. ' + jsonData.point_address1 + ', ' + jsonData.point_address2 + '
' + jsonData.point_desc + '

'); selectedPointInfo = jsonData.point_code; if (selectedPointInfo != '') { $('.tr-inpost-box .inpostship-main').append('Paczkomat został poprawnie zapisany'); } else { $('.tr-inpost-box .inpostship-main').append('Paczkomat nie został poprawnie zapisany'); } } setTimeout(function() { $('.saveInfo').remove(); }, 3000); } }); } } function updateInpostInfoCourier(id_cart, id_carrier) { $.ajax({ type: 'POST', headers: { "cache-control": "no-cache" }, url: baseDirShop + 'modules/inpostship/setCourier.php', async: false, cache: false, dataType: 'json', data: 'id_cart='+id_cart+'&id_carrier='+id_carrier, success: function(jsonData) { } }); } var inpostCGVspStepCheckout = function() { if (typeof inpostkey === "undefined") { inpostkey = 0; } if (typeof inpostkey_cod === "undefined") { inpostkey_cod = 0; } if (typeof inpostkey_week === "undefined") { inpostkey_week = 0; } if (typeof inpostkey_week_cod === "undefined") { inpostkey_week_cod = 0; } $('.custom-radio').each(function() { var inp = $(this).find('input'); if (inp.is(':checked')) { id = parseInt(inp.val()); } }); if (isNaN(id)) { id = parseInt($("input.delivery_option_radio:checked").val()); } if (isNaN(id)) { id = parseInt($(".delivery-options-list .delivery-option input:checked").val()); } if (inpostkey.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); return false; } } if (inpostkey_cod.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); return false; } } if (inpostkey_week.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); return false; } } if (inpostkey_week_cod.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); return false; } } return true; }; var inpostCGV = function() { if (typeof inpostkey === "undefined") { inpostkey = 0; } if (typeof inpostkey_cod === "undefined") { inpostkey_cod = 0; } if (typeof inpostkey_week === "undefined") { inpostkey = 0; } if (typeof inpostkey_week_cod === "undefined") { inpostkey_cod = 0; } $('.custom-radio').each(function() { var inp = $(this).find('input'); if (inp.is(':checked')) { id = parseInt(inp.val()); } }); if (isNaN(id)) { id = parseInt($("input.delivery_option_radio:checked").val()); } if (isNaN(id)) { id = parseInt($(".delivery-options-list .delivery-option input:checked").val()); } if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); if (checkoutInpost == 'steasycheckout') { $('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none'); } else if (checkoutInpost == 'supercheckout') { $('#supercheckout-agree input').removeAttr('checked'); } else { $('#cgv').parent().removeClass('checked'); } return false; } } if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) { if (selectedPointInfo == '') { $('#inpostshipmodal').modal(); if (checkoutInpost == 'steasycheckout') { $('#steco-conditions-to-approve .steco-custom-input').removeAttr('checked').next().find('i').css('display', 'none'); } else if (checkoutInpost == 'supercheckout') { $('#supercheckout-agree input').removeAttr('checked'); } else { $('#cgv').parent().removeClass('checked'); } return false; } } }; var initInpost = function(elem) { if (typeof inpostkey === "undefined") { inpostkey = []; } if (typeof inpostkey_cod === "undefined") { inpostkey_cod = []; } if (typeof inpostkey_week === "undefined") { inpostkey_week = []; } if (typeof inpostkey_week_cod === "undefined") { inpostkey_week_cod = []; } inpostCGVUncheck(); id = parseInt(elem.val()); $('.tr-inpost-box').remove(); var closest = '.delivery-option'; if (checkoutInpost == 'supercheckout') { closest = '.highlight'; $('.supercheckoutListItemInpost').remove(); } if (inpostkey.indexOf(id) > -1 || inpostkey_week.indexOf(id) > -1) { elem.closest(closest).after(createInpostBox(id)); if (nps == 1) { var obj = $('.inpostship-main'); $.ajax({ url: baseDirShop + 'modules/inpostship/ajax.php', type: 'POST', headers: {"cache-control": "no-cache"}, async: false, cache: false, dataType: 'json', data: 'action=getUserPoints', success: function (jsonData) { if (jsonData) { if (jsonData.points != '') { var htmls = '

Paczkomaty w pobliżu Twojego adresu:

'; $.each(jsonData.points, function (index, value) { htmls += '

' + value.name + '
' + value.address + '
' + value.desc + '

'; }); htmls += '
'; obj.append(htmls); } } } }); } $.ajax({ url: baseDirShop + 'module/inpostship/customerPoint', type: 'POST', headers: {"cache-control": "no-cache"}, async: false, cache: false, dataType: 'json', // data: 'action=getUserPoints', success: function (jsonData) { if (jsonData) { if (jsonData.points != '') { var htmls = '

Twoje najczęściej wybierane paczkomaty:

'; $.each(jsonData.points, function (index, value) { htmls += '

' + value.name + '
' + value.address +'
' + value.desc + '

'; }); htmls += '
'; obj.append(htmls); } } } }); if (selectedPointInfo != '' || selectedPointInfo != 'undefined') { $('.tr-inpost-box .inpostship-main').append('

'); selectedPointInfo = selectedPointInfo.replace('|| ', '
').replace(';;', '').replace(';; ', '').replace('||', '
'); $('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo); } } else if (inpostkey_cod.indexOf(id) > -1 || inpostkey_week_cod.indexOf(id) > -1) { elem.closest(closest).after(createInpostBox(id, 1)); if (nps == 1) { var obj = $('.inpostship-main'); $.ajax({ url: baseDirShop + 'modules/inpostship/ajax.php', type: 'POST', headers: {"cache-control": "no-cache"}, async: false, cache: false, dataType: 'json', data: 'action=getUserPoints&cod=1', success: function (jsonData) { if (jsonData) { if (jsonData.points != '') { var htmls = '

Paczkomaty w pobliżu Twojego adresu:

'; $.each(jsonData, function (index, value) { htmls += '

' + value.name + '
' + value.address + '
' + value.desc + '

'; }); htmls += '
'; obj.append(htmls); } } } }); } if (selectedPointInfo != '' || selectedPointInfo != 'undefined') { $('.tr-inpost-box .inpostship-main').append('

'); selectedPointInfo = selectedPointInfo.replace('|| ', '
').replace(';;', '').replace(';; ', '').replace('||', '
'); $('.tr-inpost-box .inpostship-main .point-info').html(selectedPointInfo); } } else { if (typeof courierkey === "undefined") { courierkey = []; } if (typeof courierkey_cod === "undefined") { courierkey_cod = []; } if (courierkey.indexOf(id) > -1) { updateInpostInfoCourier(cart, id); } if (courierkey_cod.indexOf(id) > -1) { updateInpostInfoCourier(cart, id); } } } function createInpostBox(idCarrier, cod = 0) { if (geoWidget == 4) { var obj = $('.inpostship-main'); var html = ''; if (isTable == 1) { html += ''; } if (checkoutInpost == 'supercheckout') { html += '
  • '; } html += '
    '; html += '' + ''; if (showWeek == 1) { // html += ''; } html += '' + '' + '' + '' + '
    Paczka w weekend (+' + weekPrice + ' zł)
    ' + 'Wybierz paczkomat z mapy' + '
    '; html += '

    '; if (checkoutInpost == 'supercheckout') { html += '
  • '; } if (isTable == 1) { html += ''; } } else { let config = 'parcelCollect'; if (cod == 1) { config = 'parcelCollectPayment'; } if (sandbox == 1) { html = ''+ ''; } else { html = '' + ''; } html += '
    Wybierz paczkomat z mapy
    '; } return html; } function afterPointSelected(point) { updateInpostInfo(cart, id, point.name); } $(document).ready(function () { $('.tr-inpost-box .inpostship-main .inpost-point').on('change', function(){ var vl = $(this).html(); if (vl != '' && vl != null && selectedPointInfo != '') { var vla = vl.split(','); updateInpostInfo(cart, inpostkey, vla[0]); } else { $('#cgv').removeAttr('checked'); $('#cgv').parent().removeClass('checked'); return false; } }); $(document).on('click', '.nearInpost', function() { var point = $(this).data('name'); var cart = $(this).data('cart'); var id = $(this).data('id'); updateInpostInfo(cart, id, point); }); $(document).on('click', '.openMap', function() { let config = 'parcelCollect', cod = $(this).data('cod'); if (cod == 1) { config = 'parcelCollectPayment'; } let html = ''; $('.load-geo-box').append(html); }) });