658 lines
31 KiB
JavaScript
658 lines
31 KiB
JavaScript
/**
|
|
*
|
|
* 2014-2023 Presta-Mod.pl Rafał Zontek
|
|
*
|
|
* NOTICE OF LICENSE
|
|
*
|
|
* Poniższy kod jest kodem płatnym, rozpowszechanie bez pisemnej zgody autora zabronione
|
|
* Moduł można zakupić na stronie Presta-Mod.pl. Modyfikacja kodu jest zabroniona,
|
|
* wszelkie modyfikacje powodują utratę gwarancji
|
|
*
|
|
* http://presta-mod.pl
|
|
*
|
|
* DISCLAIMER
|
|
*
|
|
*
|
|
* @author Presta-Mod.pl Rafał Zontek <biuro@presta-mod.pl>
|
|
* @copyright 2014-2023 Presta-Mod.pl
|
|
* @license Licecnja na jedną domenę
|
|
* Presta-Mod.pl Rafał Zontek
|
|
*
|
|
*/
|
|
pm_point_function = false;
|
|
function afterPointSelected(point) {
|
|
if (pm_point_function) {
|
|
pm_point_function(point);
|
|
}
|
|
}
|
|
|
|
$(document).ready(function() {
|
|
pm_inpostpaczkomaty_cod = false;
|
|
pm_inpostpaczkomaty_current_point = false;
|
|
pm_inpostpaczkomaty_dvopt = '';
|
|
pm_inpostpaczkomaty_firstload = false;
|
|
pm_inpostpaczkomaty_last = false;
|
|
pm_inpostpaczkomaty_multichanging = false;
|
|
pm_inpostpaczkomaty_resizeinterval = false;
|
|
pm_inpostpaczkomaty_selected_desc = '';
|
|
pm_inpostpaczkomaty_selected_name = '';
|
|
|
|
$(document).on('click','.click-pm-sender', function(){
|
|
$('.pmsender').click();
|
|
return false;
|
|
});
|
|
|
|
function setPointAdditionalDesc(point) {
|
|
if (!point) {
|
|
$('.paczkomaty-additional-desc').html('');
|
|
$('.paczkomat-input').val('');
|
|
} else {
|
|
pm_inpostpaczkomaty_selected = point.name;
|
|
pm_inpostpaczkomaty_selected_name = '<span class="name">' + point.name + ':</span> <span class="address">' + point.address.line1 + ',</span><br/><span class="address2">' + point.address.line2 + '</span>';
|
|
pm_inpostpaczkomaty_selected_desc = pm_inpostpaczkomaty_selected_name + '<br/>';
|
|
if (point.location_description != '') {
|
|
if (point.opening_hours != '') {
|
|
let desc = '';
|
|
if (point.location_description){
|
|
desc = point.location_description + ', ';
|
|
}
|
|
if (desc != '' && point.opening_hours) {
|
|
desc = desc + ' '+ point.opening_hours;
|
|
}
|
|
if (desc) {
|
|
pm_inpostpaczkomaty_selected_desc += '<span class="location">(' + desc + ')</span><br/>';
|
|
}
|
|
} else if (point.location_description) {
|
|
pm_inpostpaczkomaty_selected_desc += '<span class="location">(' + point.location_description + ')</span><br/>';
|
|
}
|
|
}
|
|
$('.paczkomat-input').val(point.name);
|
|
$('.paczkomaty-additional-desc').html(pm_inpostpaczkomaty_selected_desc);
|
|
}
|
|
}
|
|
|
|
function setPoint(point) {
|
|
setPointAdditionalDesc(point);
|
|
pm_inpostpaczkomaty_current_point = point;
|
|
|
|
$.ajax({
|
|
type: 'POST',
|
|
headers: {
|
|
"cache-control": "no-cache"
|
|
},
|
|
url: pm_inpostpaczkomaty_modulepath + '' + '?rand=' + new Date().getTime(),
|
|
async: true,
|
|
cache: false,
|
|
data: 'selmachine=1&token=' + pm_inpostpaczkomaty_token + '&pm_inpostpaczkomaty_current_cart=' + pm_inpostpaczkomaty_current_cart + '&selected=' + point.name,
|
|
success: function() {
|
|
setOrderEnabled(true);
|
|
if (pm_inpostpaczkomaty_ps == '1.6') {
|
|
if (typeof(updatePaymentMethodsDisplay) != 'undefined')
|
|
updatePaymentMethodsDisplay();
|
|
}
|
|
}
|
|
});
|
|
$('.fancybox-close').click();
|
|
}
|
|
|
|
pm_point_function = function setSelected(point) {
|
|
if ($('.overlay_pminpost').is(':visible')) {
|
|
$('.overlay_pminpost').fadeOut();
|
|
}
|
|
if ($('.tohide').length) {
|
|
$('.tohide').remove();
|
|
}
|
|
if ($('.overlay_pminpost').is(':visible')) {
|
|
$('.overlay_pminpost').fadeOut();
|
|
}
|
|
|
|
if (typeof(pm_inpostpaczkomaty_last.name) == 'undefined' || pm_inpostpaczkomaty_selected && pm_inpostpaczkomaty_last.name != pm_inpostpaczkomaty_selected.name) { //if selected
|
|
setOrderEnabled(true);
|
|
$.ajax({
|
|
url: pm_inpostpaczkomaty_point_url + point.name,
|
|
method: 'GET',
|
|
dataType: 'JSON',
|
|
success: function(params) {
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && point && point.type.length > 1) {
|
|
ph = pm_inpostpaczkomaty_label_weekend;
|
|
setPointAdditionalDesc(false);
|
|
} else {
|
|
setPointAdditionalDesc(point);
|
|
}
|
|
pm_inpostpaczkomaty_last = point;
|
|
if (pm_inpostpaczkomaty_last !== false) {
|
|
pm_inpostpaczkomaty_current_point = point;
|
|
setPoint(point);
|
|
}
|
|
}
|
|
});
|
|
} else {
|
|
if (pm_inpostpaczkomaty_selected.name != '' && pm_inpostpaczkomaty_last !== false) { //if selected
|
|
setOrderEnabled(true);
|
|
setPoint(point);
|
|
var point = pm_inpostpaczkomaty_last;
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
function loadMap(cod) {
|
|
var config = 'parcelCollect';
|
|
if (cod) {
|
|
config = 'parcelCollectPayment';
|
|
}
|
|
$.fancybox({
|
|
minWidth: '90%',
|
|
minHeight: '90%',
|
|
width: '90%',
|
|
height: '90%',
|
|
|
|
autosize: false,
|
|
content: `<inpost-geowidget
|
|
id="1"
|
|
onpoint="afterPointSelected"
|
|
token="`+pm_inpostpaczkomaty_v5_token+`"
|
|
language="pl"
|
|
config="`+config+`"
|
|
></inpost-geowidget>`});
|
|
}
|
|
|
|
function loadWidgetMap(cod) {
|
|
var types = ['parcel_locker_only'];
|
|
if (pm_inpostpaczkomaty_wpzl == '1') {
|
|
$('.paczkomat-input').paczkomaty(
|
|
'https://maps.googleapis.com/maps/api/geocode/json', {
|
|
formatItem: function(data, i, max, value, term) {
|
|
return `<span class="paczkomat_name">
|
|
${pm_inpostpaczkomaty_machine_label} ${data.name}
|
|
</span>
|
|
<span>
|
|
${data.address.line1}, ${data.address.line2}
|
|
</span>
|
|
<span>
|
|
${data.location_description}
|
|
</span>`;
|
|
},
|
|
parse: function(data) {
|
|
var mytab = [];
|
|
for (var i = 0; i < data.length; i++) {
|
|
mytab[mytab.length] = {
|
|
data: data[i],
|
|
value: data[i].name
|
|
};
|
|
}
|
|
return mytab;
|
|
},
|
|
types: types
|
|
}
|
|
)
|
|
.result(function(event, data, formatted) {
|
|
if (data.status != 404) {
|
|
$(this).val(data.name);
|
|
$('#PMINPOSTPACZKOMATY_MACHINE').val(data.name);
|
|
pm_inpostpaczkomaty_selected = data;
|
|
|
|
$.ajax({
|
|
url: pm_inpostpaczkomaty_point_url + data.name,
|
|
method: 'GET',
|
|
dataType: 'JSON',
|
|
success: function(point) {
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && point && point.type.length > 1) {
|
|
ph = pm_inpostpaczkomaty_label_weekend;
|
|
setPointAdditionalDesc(false);
|
|
} else {
|
|
setPointAdditionalDesc(point);
|
|
}
|
|
pm_inpostpaczkomaty_last = point;
|
|
pm_point_function(point);;
|
|
}
|
|
});
|
|
}
|
|
}).getPaczkomatName();
|
|
}
|
|
|
|
pm_inpostpaczkomaty_cod = cod;
|
|
}
|
|
|
|
function getMyObject(t, value) {
|
|
if (pm_inpostpaczkomaty_opc == 'supercheckout_17' && $('#select-widget').length == 0) {
|
|
$('#hook-display-after-carrier').append(value);
|
|
$('#select-widget').css('height','140px');
|
|
}
|
|
else if (pm_inpostpaczkomaty_opc == 'steasycheckout_17' && $('#select-widget').length == 0) {
|
|
if (pm_inpostpaczkomaty_display_place == 1) {
|
|
return $('.delivery-options-list').append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('.delivery-options').prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).parent().parent().parent().after().append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).parent().parent().parent().before().prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 5) {
|
|
return $('.hook-display-before-carrier').append(value);
|
|
} else {
|
|
return $('#' + t).parent().closest('.carrier-extra-content').prepend(value);
|
|
}
|
|
return;
|
|
} else if (typeof(OnePageCheckoutPS) != 'undefined') {
|
|
if (pm_inpostpaczkomaty_display_place == 1) {
|
|
return $('#' + t).closest('.delivery-options').append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('.delivery-options').prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).closest('.row').after(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).closest('.row').before(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 5) {
|
|
return $('.hook-display-before-carrier').append(value);
|
|
} else {
|
|
return $('#' + t).parent().closest('.carrier-extra-content').prepend(value);
|
|
}
|
|
} else if (pm_inpostpaczkomaty_ps == '1.6') {
|
|
if ($('.supercheckout_shipping_option').length) {
|
|
$('.opc_shipping_method').append(value);
|
|
$('#select-widget').css('height', '128px');
|
|
return '';
|
|
}
|
|
if (pm_inpostpaczkomaty_display_place == 1) {
|
|
$('#' + t).closest('table').parent().append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('table').parent().prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).parent().parent().parent().parent().parent().find('td:eq(2)').append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).parent().parent().parent().parent().parent().find('td:eq(2)').prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 5) {
|
|
return $('#HOOK_BEFORECARRIER').append(value);
|
|
} else {
|
|
return $('.hook_extracarrier').append(value);
|
|
}
|
|
} else {
|
|
if ($('.supercheckout-blocks').length) {
|
|
var colspan = $('#' + t).closest('tr').find('td').length
|
|
if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).closest('tr').after('<tr><td style="width: 100% !important;" colspan="' + colspan + '">' + value + '</td></tr>');
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).closest('tr').before('<tr><td style="width: 100% !important;" colspan="' + colspan + '">' + value + '</td></tr>');
|
|
} else if (pm_inpostpaczkomaty_display_place == 1) {
|
|
return $('#' + t).closest('table').after(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('table').before(value);
|
|
}
|
|
} else if ($('#module-thecheckout-order').length) {
|
|
if (pm_inpostpaczkomaty_display_place == 1) {
|
|
return $('#' + t).closest('.delivery-options').after(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('.delivery-options').before(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).closest('.delivery-option-row').after('<div class="delivery-option-row row delivery-option">' + value + '</div>');
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).closest('.delivery-option-row').before('<div class="delivery-option-row row delivery-option">' + value + '</div>');
|
|
} else if (pm_inpostpaczkomaty_display_place == 5) {
|
|
return $('.hook-display-before-carrier').append(value);
|
|
} else {
|
|
return $('#' + t).parent().closest('.carrier-extra-content').prepend(value);
|
|
}
|
|
} else {
|
|
if (pm_inpostpaczkomaty_display_place == 1) {
|
|
return $('#' + t).closest('.delivery-options').append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 2) {
|
|
return $('#' + t).closest('.delivery-options').prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 3) {
|
|
return $('#' + t).closest('.row').append(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 4) {
|
|
return $('#' + t).closest('.row').prepend(value);
|
|
} else if (pm_inpostpaczkomaty_display_place == 5) {
|
|
return $('.hook-display-before-carrier').append(value);
|
|
} else {
|
|
return $('#' + t).parent().closest('.carrier-extra-content').prepend(value);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function getInpostHtml(pm_inpostpaczkomaty_selected_label, pm_inpostpaczkomaty_selected_name, pm_inpostpaczkomaty_placeholder, pm_inpostpaczkomaty_label) {
|
|
var ph = pm_inpostpaczkomaty_placeholder
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && pm_inpostpaczkomaty_current_point && pm_inpostpaczkomaty_current_point.type.length > 1) {
|
|
pm_inpostpaczkomaty_selected = '';
|
|
pm_inpostpaczkomaty_selected_name = '';
|
|
ph = pm_inpostpaczkomaty_label_weekend;
|
|
}
|
|
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val())) { // reload page
|
|
ph = pm_inpostpaczkomaty_label_weekend;
|
|
}
|
|
|
|
var sclass = '';
|
|
var col = 'col-50';
|
|
if ($('.supercheckout-blocks').length || $('#module-thecheckout-order').length) {
|
|
col = 'col-100';
|
|
}
|
|
if (pm_inpostpaczkomaty_opc == 'steasycheckout_17') {
|
|
sclass = 'widget-steasycheckout_17';
|
|
col = 'col-100';
|
|
}
|
|
var html = '<div class="'+sclass+'" id="select-widget"><div class="col-100"><span class="paczkomaty-label">' + pm_inpostpaczkomaty_selected_label + '</span></div><div class="' + col + '"><input value="' + pm_inpostpaczkomaty_selected + '" type="text" class="paczkomat-input" ';
|
|
if (pm_inpostpaczkomaty_wpzl == '1') {
|
|
html = html + 'placeholder="' + ph;
|
|
} else {
|
|
html = html + 'disabled="disabled" placeholder="' + pm_inpostpaczkomaty_placeholder2;
|
|
}
|
|
html = html + '" /></div><div class="' + col + '"><button class="pmsender" id="popup-btn">' + pm_inpostpaczkomaty_label + '</button></div><div><span class="paczkomaty-additional-desc">' + pm_inpostpaczkomaty_selected_desc +'</span></div></div>';
|
|
return html;
|
|
}
|
|
|
|
|
|
|
|
function setOrderEnabled(enabled) {
|
|
if (pm_inpostpaczkomaty_selected != '') {
|
|
enabled = true;
|
|
}
|
|
|
|
if (enabled) {
|
|
if (pm_inpostpaczkomaty_opc == 'ets_onepagecheckout_17') {
|
|
if ($('.paczkomaty-message').length != 0) {
|
|
$('.paczkomaty-message').remove();
|
|
}
|
|
$('button[name="submitCompleteMyOrder"]').prop('disabled', 0);
|
|
}
|
|
else if ($('#spstepcheckout').length) {
|
|
$('.paczkomaty-message').remove();
|
|
$('#payment-confirmation').find('button[type="submit"]').show();
|
|
return;
|
|
}
|
|
else if (pm_inpostpaczkomaty_opc == 'steasycheckout_17') {
|
|
$('.steasy-paczkomat-select-label').remove();
|
|
$('.steco_confirmation_btn').show();
|
|
return;
|
|
} else {
|
|
if ($('.confirm_button').length && $('.confirm_button').attr('onclick') == "$.confirm({title: '',content: '<strong>" + pm_inpostpaczkomaty_selected_label + "</strong>',buttons: {cancel: {text: 'OK'}}}); $('.pmsender').click(); return false;") {
|
|
$('.confirm_button').attr('onclick', "paymentModuleConfirm();")
|
|
}
|
|
$('button[name="confirmDeliveryOption"]').removeAttr('disabled');
|
|
$('#supercheckout_confirm_order').show();
|
|
$('#pm_select_machine').hide();
|
|
$('#confirm_order').removeAttr('disabled').show();
|
|
if (typeof(OnePageCheckoutPS) != 'undefined') {
|
|
if ($('#pm_select_machine').length == 0) {
|
|
$('#btn_place_order').after('<button disabled="disabled" id="pm_select_machine" style="background: none; background-color: #aaa; display: block; padding: 5px; font-size: 18px; color: white; margin-top: 0px;float: right;" class="orangebutton2">' + pm_inpostpaczkomaty_selected_label + '</button>');
|
|
}
|
|
$('#btn_place_order').show();
|
|
}
|
|
}
|
|
} else {
|
|
if (pm_inpostpaczkomaty_opc == 'ets_onepagecheckout_17') {
|
|
if ($('.paczkomaty-message').length == 0) {
|
|
$('button[name="submitCompleteMyOrder"]').parent().prepend('<div class="alert alert-warning paczkomaty-message">'+pm_inpostpaczkomaty_selected_label+'</div>');
|
|
}
|
|
$('button[name="submitCompleteMyOrder"]').prop('disabled', 1);
|
|
}
|
|
else if ($('#spstepcheckout').length) {
|
|
$('#payment-confirmation').find('button[type="submit"]').hide();
|
|
if ($('.paczkomaty-message').length == 0) {
|
|
$('#payment-confirmation').append('<div class="paczkomaty-message alert alert-warning">'+pm_inpostpaczkomaty_selected_label+'</div>');
|
|
}
|
|
}
|
|
else if (pm_inpostpaczkomaty_opc == 'steasycheckout_17') {
|
|
if ($('.steasy-paczkomat-select-label').length == 0) {
|
|
$('.steasy-paczkomat-select-label').remove();
|
|
$('.steco_confirmation_btn').parent().parent().append('<div class="steasy-paczkomat-select-label"><a href="#" class="click-pm-sender btn btn-default" style="color: #fff; background-color: #8e021d; font-size: 12px; border-color: rgba(0, 0, 0, 0);">'+label+'</a></div>')
|
|
}
|
|
$('.steco_confirmation_btn').hide();
|
|
return;
|
|
} else {
|
|
if ($('.confirm_button').length && $('.confirm_button').attr('onclick') == 'paymentModuleConfirm();') {
|
|
|
|
$('.confirm_button').attr('onclick', "$.confirm({title: '',content: '<strong>" + pm_inpostpaczkomaty_selected_label + "</strong>',buttons: {cancel: {text: 'OK'}}}); $('.pmsender').click(); return false;")
|
|
}
|
|
$('#confirm_order').attr('disabled', 'disabled').hide();
|
|
$('#supercheckout_confirm_order').hide();
|
|
$('button[name="confirmDeliveryOption"]').attr('disabled', 'disabled');
|
|
$('#supercheckout_confirm_order').hide();
|
|
$('#pm_select_machine').show();
|
|
if (typeof(OnePageCheckoutPS) != 'undefined') {
|
|
if ($('#pm_select_machine').length == 0) {
|
|
$('#btn_place_order').after('<button disabled="disabled" id="pm_select_machine" style="background: none; background-color: #aaa; display: block; padding: 5px; font-size: 18px; color: white; margin-top: 0px;float: right;" class="rangebutton2">' + pm_inpostpaczkomaty_selected_label + '</button>');
|
|
}
|
|
$('#btn_place_order').hide();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
function checkCarrierPaczkomatyEof(id) {
|
|
if ($.inArray(parseInt(id).toString(), pm_inpostpaczkomaty_carrier_eof) != -1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function checkCarrierPaczkomaty(id) {
|
|
if ($.inArray(parseInt(id).toString(), pm_inpostpaczkomaty_carrier) != -1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function checkCarrierPaczkomatyCod(id) {
|
|
if ($.inArray(parseInt(id).toString(), pm_inpostpaczkomaty_carrier_cod) != -1) {
|
|
return true;
|
|
} else {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
function checkCarrierPaczkomatyAll(id) {
|
|
return checkCarrierPaczkomaty(id) || checkCarrierPaczkomatyCod(id);
|
|
}
|
|
|
|
function onChangeDeliveryOptionWidget(at, ajax, type) {
|
|
if (pm_inpostpaczkomaty_multichanging == false) {
|
|
pm_inpostpaczkomaty_multichanging = true;
|
|
setTimeout(function() {
|
|
if ($('#select-widget').length) {
|
|
$('#select-widget').remove();
|
|
}
|
|
var t = $(at).attr('id');
|
|
var cod = false;
|
|
selected = false;
|
|
if (checkCarrierPaczkomaty(parseInt($(at).val()))) {
|
|
enabled = pm_inpostpaczkomaty_selected == '' ? false : true;
|
|
setOrderEnabled(enabled);
|
|
selected = true;
|
|
cod = false;
|
|
} else if (checkCarrierPaczkomatyCod($(at).val())) {
|
|
enabled = pm_inpostpaczkomaty_selected == '' ? false : true;
|
|
setOrderEnabled(enabled);
|
|
selected = true;
|
|
cod = true;
|
|
} else {
|
|
setOrderEnabled(true);
|
|
}
|
|
if (selected) {
|
|
getMyObject(t, getInpostHtml(pm_inpostpaczkomaty_selected_label, pm_inpostpaczkomaty_selected_name, pm_inpostpaczkomaty_placeholder, pm_inpostpaczkomaty_label));
|
|
loadWidgetMap(cod);
|
|
}
|
|
pm_inpostpaczkomaty_multichanging = false;
|
|
}, 500)
|
|
}
|
|
}
|
|
|
|
function getCheckoutElement() {
|
|
pm_inpostpaczkomaty_dvopt = '';
|
|
if ($('.carrier_action').find('input[name="id_carrier"]').length) {
|
|
pm_inpostpaczkomaty_dvopt = 'input[name="id_carrier"]';
|
|
return ;
|
|
} else if (typeof(OnePageCheckoutPS) != 'undefined') {
|
|
pm_inpostpaczkomaty_dvopt = '.delivery_option_radio';
|
|
} else if ($('.delivery-options').length) {
|
|
pm_inpostpaczkomaty_dvopt = '.delivery-options input[type="radio"]';
|
|
} else if ($('.delivery_option_radio').length || $('.supercheckout-blocks').length) {
|
|
pm_inpostpaczkomaty_dvopt = '.delivery_option_radio';
|
|
} else {
|
|
pm_inpostpaczkomaty_dvopt = '.delivery-option input[type="radio"]';
|
|
}
|
|
}
|
|
|
|
getCheckoutElement();
|
|
|
|
$(document).on('click', '#checkout-payment-step', function() {
|
|
if (pm_inpostpaczkomaty_selected.length == 0 && checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val())) {
|
|
$('#checkout-delivery-step').click();
|
|
$('.pmsender').fadeOut().fadeIn().fadeOut().fadeIn();
|
|
} else return true;
|
|
})
|
|
|
|
if ($('.js-current-step').is('#checkout-payment-step')) {
|
|
$('#checkout-payment-step').click();
|
|
}
|
|
|
|
$(document).on('change', pm_inpostpaczkomaty_dvopt + ' ', function() {
|
|
onChangeDeliveryOptionWidget(this, true);
|
|
})
|
|
|
|
if (pm_inpostpaczkomaty_ps == '1.6' || pm_inpostpaczkomaty_opc == 'spstepcheckout_17') {
|
|
$(document).ajaxComplete(function(event, xhr, settings) {
|
|
if (typeof(settings.data) != 'undefined' && settings.data.toString().indexOf('updateCarrier') != -1 ||
|
|
typeof(settings.data) != 'undefined' && settings.data.toString().indexOf('updateAddressesSelected') != -1) {
|
|
onChangeDeliveryOptionWidget($(pm_inpostpaczkomaty_dvopt + ':checked'), true);
|
|
}
|
|
if ($(pm_inpostpaczkomaty_dvopt + ':checked').val() != 'undefined') {
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && pm_inpostpaczkomaty_selected == '') {
|
|
setOrderEnabled(false);
|
|
}
|
|
}
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val())) {
|
|
setTimeout(function() {
|
|
if ($('.pmsender').length == 0) {
|
|
onChangeDeliveryOptionWidget($(pm_inpostpaczkomaty_dvopt + ':checked'), true);
|
|
}
|
|
}, 300)
|
|
setOrderEnabled(false);
|
|
}
|
|
});
|
|
} else {
|
|
$(document).ajaxComplete(function(event, xhr, settings) {
|
|
if ($(pm_inpostpaczkomaty_dvopt + ':checked').val() != 'undefined') {
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && pm_inpostpaczkomaty_selected == '') {
|
|
setOrderEnabled(false);
|
|
} else {
|
|
setOrderEnabled(true);
|
|
}
|
|
if ($('.supercheckout-blocks').length) {
|
|
if ($('.pmsender').length == 0) {
|
|
onChangeDeliveryOptionWidget($(pm_inpostpaczkomaty_dvopt + ':checked'), true);
|
|
}
|
|
}
|
|
}
|
|
});
|
|
$(document).ajaxStart(function(event, xhr, settings) {
|
|
if ($(pm_inpostpaczkomaty_dvopt + ':checked').val() != 'undefined') {
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && pm_inpostpaczkomaty_selected == '') {
|
|
setOrderEnabled(false);
|
|
} else {
|
|
setOrderEnabled(true);
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val())) {
|
|
onChangeDeliveryOptionWidget($(pm_inpostpaczkomaty_dvopt + ':checked'), false);
|
|
pm_inpostpaczkomaty_firstload = true;
|
|
}
|
|
$(document).on('click', '.paczkomat-input', function() {
|
|
$('#js-delivery').removeAttr('id');
|
|
$('.delivery-option').find('').parent().attr('id', 'js-delivery');
|
|
});
|
|
|
|
var pm_inpostpaczkomaty_longloading2 = setInterval(function() {
|
|
if (pm_inpostpaczkomaty_dvopt == '') {
|
|
getCheckoutElement();
|
|
}
|
|
if ($('#supercheckout_confirm_order').length && $('#supercheckout_confirm_order').parent().find('#wybierzpaczkomat').length == 0) {
|
|
$('#supercheckout_confirm_order').parent().append('<button disabled="disabled" id="wybierzpaczkomat" style="background: none; background-color: #aaa; display: none; padding: 10px; font-size: 18px; color: white; margin-top: 10px;" class="orangebutton2">' + pm_inpostpaczkomaty_selected_label + '</button>');
|
|
} else if ($('#module-thecheckout-order').length && $('#confirm_order').parent().find('#wybierzpaczkomat').length == 0) {
|
|
$('#confirm_order').parent().append('<button disabled="disabled" id="wybierzpaczkomat" style="background: none; background-color: #aaa; display: none; padding: 10px; font-size: 18px; color: white; margin-top: 10px;" class="orangebutton2">' + pm_inpostpaczkomaty_selected_label + '</button>');
|
|
}
|
|
|
|
if ($(pm_inpostpaczkomaty_dvopt + ':checked').val() != 'undefined') {
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val())) {
|
|
if ($('.pmsender').length == 0) {
|
|
onChangeDeliveryOptionWidget($(pm_inpostpaczkomaty_dvopt + ':checked'), true);
|
|
clearInterval(pm_inpostpaczkomaty_longloading2);
|
|
}
|
|
}
|
|
}
|
|
}, 500)
|
|
|
|
$(document).on('click', '.pmsender', function() {
|
|
loadMap(pm_inpostpaczkomaty_cod);
|
|
return false;
|
|
})
|
|
|
|
|
|
pm_inpostpaczkomaty_overlay = $('<div class="overlay_pminpost"></div>');
|
|
$('body').append(pm_inpostpaczkomaty_overlay);
|
|
pm_inpostpaczkomaty_overlay.hide();
|
|
|
|
if (typeof(acceptCGV) !== 'undefined') {
|
|
var copyacceptCGV = acceptCGV;
|
|
acceptCGV = function() {
|
|
if (checkCarrierPaczkomatyAll($(pm_inpostpaczkomaty_dvopt + ':checked').val())) {
|
|
var label = pm_inpostpaczkomaty_selected_label;
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && pm_inpostpaczkomaty_current_point && pm_inpostpaczkomaty_current_point.type.length > 1) {
|
|
pm_inpostpaczkomaty_selected = '';
|
|
pm_inpostpaczkomaty_selected_name = '';
|
|
label = pm_inpostpaczkomaty_label_weekend
|
|
}
|
|
if (pm_inpostpaczkomaty_selected == '') {
|
|
$.confirm({
|
|
title: '',
|
|
content: '<strong>' + label + '</strong>',
|
|
buttons: {
|
|
custom: {
|
|
text: pm_inpostpaczkomaty_label,
|
|
btnClass: 'btn btn-primary',
|
|
action: function() {
|
|
this.close();
|
|
$('.pmsender').click();
|
|
}
|
|
},
|
|
cancel: {
|
|
text: 'OK'
|
|
}
|
|
}
|
|
});
|
|
|
|
return false;
|
|
}
|
|
|
|
}
|
|
return copyacceptCGV();
|
|
}
|
|
}
|
|
|
|
|
|
$(document).on('click', '.widget-modal__close', function() {
|
|
$('.overlay_pminpost').fadeOut();
|
|
});
|
|
if (pm_inpostpaczkomaty_selected != '') {
|
|
$.ajax({
|
|
url: pm_inpostpaczkomaty_point_url + pm_inpostpaczkomaty_selected,
|
|
method: 'GET',
|
|
dataType: 'JSON',
|
|
success: function(point) {
|
|
if (checkCarrierPaczkomatyEof($(pm_inpostpaczkomaty_dvopt + ':checked').val()) && point && point.type.length > 1) {
|
|
ph = pm_inpostpaczkomaty_label_weekend;
|
|
} else {
|
|
setPointAdditionalDesc(point);
|
|
}
|
|
pm_inpostpaczkomaty_last = point;
|
|
}
|
|
});
|
|
}
|
|
}); |