first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,328 @@
function dhl_ajax( dhl_action, count ) {
var dhl_insurance = 0;
if ( jQuery("#dhl_"+count+"_dhl_insurance").is(':checked') ) {
dhl_insurance = jQuery("#dhl_"+count+"_dhl_insurance").val();
}
var dhl_cod = 0;
if ( jQuery("#dhl_"+count+"_dhl_cod").is(':checked') ) {
dhl_cod = jQuery("#dhl_"+count+"_dhl_cod").val();
}
var dhl_additional_packages = [];
var additional_package_count = 0;
jQuery(".dhl_additional_package").each(function(){
var additional_key = jQuery(this).attr('data-key');
var additional_package = {};
additional_package.dhl_package_type = jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_type").val();
additional_package.dhl_package_weight = jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_weight").val();
additional_package.dhl_package_width = jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_width").val();
additional_package.dhl_package_length = jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_length").val();
additional_package.dhl_package_height = jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_height").val();
dhl_additional_packages[additional_package_count] = additional_package;
additional_package_count++;
});
var ajax_data = {
'action' : 'wpdesk_dhl',
'dhl_action' : dhl_action,
'security' : jQuery("#dhl_ajax_nonce").val(),
'post_id' : jQuery("#dhl_"+count+"_post_id").val(),
'key' : jQuery("#dhl_"+count+"_key").val(),
'dhl_product' : jQuery("#dhl_"+count+"_dhl_product").val(),
'dhl_package_type' : jQuery("#dhl_"+count+"_dhl_package_type").val(),
'dhl_package_weight' : jQuery("#dhl_"+count+"_dhl_package_weight").val(),
'dhl_package_width' : jQuery("#dhl_"+count+"_dhl_package_width").val(),
'dhl_package_length' : jQuery("#dhl_"+count+"_dhl_package_length").val(),
'dhl_package_height' : jQuery("#dhl_"+count+"_dhl_package_height").val(),
'dhl_shipment_date' : jQuery("#dhl_"+count+"_dhl_shipment_date").val(),
'dhl_insurance' : dhl_insurance,
'dhl_insurance_value' : jQuery("#dhl_"+count+"_dhl_insurance_value").val(),
'dhl_cod' : dhl_cod,
'dhl_cod_value' : jQuery("#dhl_"+count+"_dhl_cod_value").val(),
'dhl_content' : jQuery("#dhl_"+count+"_dhl_content").val(),
'dhl_comment' : jQuery("#dhl_"+count+"_dhl_comment").val(),
'additional_packages' : dhl_additional_packages,
};
jQuery.ajax({
url : dhl_ajax_object.ajax_url,
data : ajax_data,
method : 'POST',
dataType: 'JSON',
success: function( data ) {
if ( data != 0 ) {
jQuery('#dhl_metabox>.inside').html(data.content);
dhl_init();
}
},
error: function ( xhr, ajaxOptions, thrownError ) {
alert( xhr.status + ': ' + thrownError );
},
complete: function() {
jQuery('.dhl-button').removeAttr('disabled','disabled');
jQuery('.dhl-spinner').css({visibility: 'hidden'});
}
});
}
jQuery(document).on('click','.dhl-button-create', function(e) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dhl-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
dhl_ajax('create_package', count);
}
var id = jQuery(this).attr('data-id');
if ( typeof id != 'undefined' ) {
e.stopImmediatePropagation();
e.preventDefault();
var id = fs_id(this);
var fs_action = 'send';
fs_ajax( this, id, fs_action );
}
})
jQuery(document).on('click','.dhl-button-save', function(e) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dhl-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dhl_ajax('save_package', count);
}
var id = jQuery(this).attr('data-id');
if ( typeof id != 'undefined' ) {
e.stopImmediatePropagation();
e.preventDefault();
var id = fs_id(this);
var fs_action = 'save';
fs_ajax( this, id, fs_action );
}
})
jQuery(document).on('click','.dhl-button-delete', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery('.dhl-button').attr('disabled','disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dhl_ajax( 'delete_package', count );
})
jQuery(document).on('click','.dhl-button-delete-package', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery(this).parent().remove();
})
jQuery(document).on('click','.dhl-button-delete-created', function( e ) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dhl-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dhl_ajax('delete_created_package', count);
}
var id = jQuery(this).attr('data-id');
if ( typeof id != 'undefined' ) {
e.stopImmediatePropagation();
e.preventDefault();
var id = fs_id(this);
var fs_action = 'cancel';
fs_ajax( this, id, fs_action );
}
})
jQuery(document).on('click','.dhl-button-add', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery('.dhl-button').attr('disabled','disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var ajax_data = {
'action' : 'wpdesk_dhl',
'dhl_action' : 'add_package',
'security' : jQuery("#dhl_ajax_nonce").val(),
'post_id' : jQuery("input[name=post_id]").val(),
};
jQuery.ajax({
url : dhl_ajax_object.ajax_url,
data : ajax_data,
method : 'POST',
dataType: 'JSON',
success: function( data ) {
if ( data != 0 ) {
jQuery('#dhl_metabox>.inside').html(data.content);
dhl_init();
}
},
error: function ( xhr, ajaxOptions, thrownError ) {
alert( xhr.status + ': ' + thrownError );
},
complete: function() {
jQuery('.dhl-button').removeAttr('disabled','disabled');
jQuery('.dhl-spinner').css({visibility: 'hidden'});
}
});
})
jQuery(document).on('click','.dhl-button-add-package', function() {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
var count_additional = parseInt(jQuery(this).attr('data-count_additional')) + 1;
jQuery(this).attr('data-count_additional', count_additional);
var html = jQuery('#dhl_additional_package_template_' + count).html()
html = html.split('_additional_key_').join(count_additional);
html = html.split('_count_').join(count);
jQuery(this).parent().before(html);
}
var id = jQuery(this).attr('data-id');
if ( typeof id != 'undefined' ) {
var count_additional = parseInt(jQuery(this).attr('data-count_additional')) + 1;
jQuery(this).attr('data-count_additional', count_additional);
var html = jQuery('#dhl_additional_package_template_' + id).html()
html = html.split('_additional_key_').join(count_additional);
html = html.split('_count_').join(count);
jQuery(this).parent().before(html);
}
})
jQuery(document).on('click','.dhl-button-print', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery('.dhl-button').attr('disabled','disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
var ajax_data = {
'action' : 'wpdesk_dhl',
'dhl_action' : 'print_label',
'security' : jQuery("#dhl_ajax_nonce").val(),
'post_id' : jQuery("input[name=post_id]").val(),
'shipment_id' : jQuery(this).attr('data-shipment-id'),
'key' : jQuery("#dhl_"+count+"_key").val(),
};
jQuery.ajax({
url : dhl_ajax_object.ajax_url,
data : ajax_data,
method : 'POST',
dataType: 'JSON',
success: function( data ) {
jQuery('#print_message_' + data.post.shipment_id).html(data.message);
},
error: function ( xhr, ajaxOptions, thrownError ) {
alert( xhr.status + ': ' + thrownError );
},
complete: function() {
jQuery('.dhl-button').removeAttr('disabled','disabled');
jQuery('.dhl-spinner').css({visibility: 'hidden'});
}
});
})
jQuery(document).on('click','.dhl-button-label', function() {
var shipment_id = jQuery(this).attr('data-shipment-id');
var url = dhl_ajax_object.ajax_url + '?action=wpdesk_dhl&dhl_action=get_label&security=' + jQuery("#dhl_ajax_nonce").val();
url = url + '&shipment_id=' + shipment_id;
url = url + '&post_id=' + jQuery("input[name=post_id]").val();
var count = jQuery(this).attr('data-count');
url = url + '&key=' + jQuery("#dhl_"+count+"_key").val(),
window.open( url, '_blank');
})
jQuery(document).on('change','.dhl-package-type', function() {
if ( jQuery(this).val() == 'ENVELOPE' ) {
jQuery(this).parent().parent().find('.dhl-weight').hide();
jQuery(this).parent().parent().find('.dhl-dimensions').hide();
}
else {
jQuery(this).parent().parent().find('.dhl-weight').show();
jQuery(this).parent().parent().find('.dhl-dimensions').show();
}
})
jQuery(document).on('change','.dhl-product', function() {
if ( jQuery(this).val() == 'parcelshop' ) {
jQuery(this).parent().parent().find('div.dhl-parcelshop').show();
jQuery(this).parent().parent().parent().find('.dhl-value').parent().hide();
jQuery(this).closest('.dhl-package').find('.dhl_services').closest('.form-row').hide();
}
else {
jQuery(this).parent().parent().find('div.dhl-parcelshop').hide();
jQuery(this).parent().parent().parent().find('.dhl-cod').parent().parent().show();
jQuery(this).parent().parent().parent().find('.dhl-value').parent().show();
jQuery(this).closest('.dhl-package').find('.dhl_services').closest('.form-row').show();
}
})
jQuery(document).on('change','.dhl-insurance', function() {
if ( jQuery(this).is(':checked') ) {
jQuery(this).closest('.dhl-package').find('.dhl-insurance-value').show();
}
else {
jQuery(this).closest('.dhl-package').find('.dhl-insurance-value').hide();
}
})
jQuery(document).on('change','.dhl-cod', function() {
if ( jQuery(this).is(':checked') ) {
jQuery(this).closest('.dhl-package').find('.dhl-cod-value').show();
}
else {
jQuery(this).closest('.dhl-package').find('.dhl-cod-value').hide();
}
})
function dhl_init() {
jQuery('.dhl-package-type').each(function(){
jQuery(this).change();
})
jQuery('.dhl-insurance').each(function(){
jQuery(this).change();
})
jQuery('.dhl-cod').each(function(){
jQuery(this).change();
})
jQuery('.dhl-product').each(function(){
jQuery(this).change();
})
jQuery('.dhl-disabled').each(function(){
jQuery(this).prop('disabled',true);
})
jQuery( '.wc-enhanced-select.dhl_services' ).selectWoo();
}
dhl_init();

View File

@@ -0,0 +1,36 @@
function dhl_ajax(dhl_action,count){var dhl_insurance=0;if(jQuery("#dhl_"+count+"_dhl_insurance").is(':checked')){dhl_insurance=jQuery("#dhl_"+count+"_dhl_insurance").val()}
var dhl_cod=0;if(jQuery("#dhl_"+count+"_dhl_cod").is(':checked')){dhl_cod=jQuery("#dhl_"+count+"_dhl_cod").val()}
var dhl_additional_packages=[];var additional_package_count=0;jQuery(".dhl_additional_package").each(function(){var additional_key=jQuery(this).attr('data-key');var additional_package={};additional_package.dhl_package_type=jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_type").val();additional_package.dhl_package_weight=jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_weight").val();additional_package.dhl_package_width=jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_width").val();additional_package.dhl_package_length=jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_length").val();additional_package.dhl_package_height=jQuery("#dhl_"+count+"_"+additional_key+"_dhl_package_height").val();dhl_additional_packages[additional_package_count]=additional_package;additional_package_count++});var ajax_data={'action':'wpdesk_dhl','dhl_action':dhl_action,'security':jQuery("#dhl_ajax_nonce").val(),'post_id':jQuery("#dhl_"+count+"_post_id").val(),'key':jQuery("#dhl_"+count+"_key").val(),'dhl_product':jQuery("#dhl_"+count+"_dhl_product").val(),'dhl_package_type':jQuery("#dhl_"+count+"_dhl_package_type").val(),'dhl_package_weight':jQuery("#dhl_"+count+"_dhl_package_weight").val(),'dhl_package_width':jQuery("#dhl_"+count+"_dhl_package_width").val(),'dhl_package_length':jQuery("#dhl_"+count+"_dhl_package_length").val(),'dhl_package_height':jQuery("#dhl_"+count+"_dhl_package_height").val(),'dhl_shipment_date':jQuery("#dhl_"+count+"_dhl_shipment_date").val(),'dhl_insurance':dhl_insurance,'dhl_insurance_value':jQuery("#dhl_"+count+"_dhl_insurance_value").val(),'dhl_cod':dhl_cod,'dhl_cod_value':jQuery("#dhl_"+count+"_dhl_cod_value").val(),'dhl_content':jQuery("#dhl_"+count+"_dhl_content").val(),'dhl_comment':jQuery("#dhl_"+count+"_dhl_comment").val(),'additional_packages':dhl_additional_packages,};jQuery.ajax({url:dhl_ajax_object.ajax_url,data:ajax_data,method:'POST',dataType:'JSON',success:function(data){if(data!=0){jQuery('#dhl_metabox>.inside').html(data.content);dhl_init()}},error:function(xhr,ajaxOptions,thrownError){alert(xhr.status+': '+thrownError)},complete:function(){jQuery('.dhl-button').removeAttr('disabled','disabled');jQuery('.dhl-spinner').css({visibility:'hidden'})}})}
jQuery(document).on('click','.dhl-button-create',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});dhl_ajax('create_package',count)}
var id=jQuery(this).attr('data-id');if(typeof id!='undefined'){e.stopImmediatePropagation();e.preventDefault();var id=fs_id(this);var fs_action='send';fs_ajax(this,id,fs_action)}})
jQuery(document).on('click','.dhl-button-save',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dhl_ajax('save_package',count)}
var id=jQuery(this).attr('data-id');if(typeof id!='undefined'){e.stopImmediatePropagation();e.preventDefault();var id=fs_id(this);var fs_action='save';fs_ajax(this,id,fs_action)}})
jQuery(document).on('click','.dhl-button-delete',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dhl_ajax('delete_package',count)})
jQuery(document).on('click','.dhl-button-delete-package',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery(this).parent().remove()})
jQuery(document).on('click','.dhl-button-delete-created',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dhl_ajax('delete_created_package',count)}
var id=jQuery(this).attr('data-id');if(typeof id!='undefined'){e.stopImmediatePropagation();e.preventDefault();var id=fs_id(this);var fs_action='cancel';fs_ajax(this,id,fs_action)}})
jQuery(document).on('click','.dhl-button-add',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var ajax_data={'action':'wpdesk_dhl','dhl_action':'add_package','security':jQuery("#dhl_ajax_nonce").val(),'post_id':jQuery("input[name=post_id]").val(),};jQuery.ajax({url:dhl_ajax_object.ajax_url,data:ajax_data,method:'POST',dataType:'JSON',success:function(data){if(data!=0){jQuery('#dhl_metabox>.inside').html(data.content);dhl_init()}},error:function(xhr,ajaxOptions,thrownError){alert(xhr.status+': '+thrownError)},complete:function(){jQuery('.dhl-button').removeAttr('disabled','disabled');jQuery('.dhl-spinner').css({visibility:'hidden'})}})})
jQuery(document).on('click','.dhl-button-add-package',function(){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){var count_additional=parseInt(jQuery(this).attr('data-count_additional'))+1;jQuery(this).attr('data-count_additional',count_additional);var html=jQuery('#dhl_additional_package_template_'+count).html()
html=html.split('_additional_key_').join(count_additional);html=html.split('_count_').join(count);jQuery(this).parent().before(html)}
var id=jQuery(this).attr('data-id');if(typeof id!='undefined'){var count_additional=parseInt(jQuery(this).attr('data-count_additional'))+1;jQuery(this).attr('data-count_additional',count_additional);var html=jQuery('#dhl_additional_package_template_'+id).html()
html=html.split('_additional_key_').join(count_additional);html=html.split('_count_').join(count);jQuery(this).parent().before(html)}})
jQuery(document).on('click','.dhl-button-print',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dhl-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');var ajax_data={'action':'wpdesk_dhl','dhl_action':'print_label','security':jQuery("#dhl_ajax_nonce").val(),'post_id':jQuery("input[name=post_id]").val(),'shipment_id':jQuery(this).attr('data-shipment-id'),'key':jQuery("#dhl_"+count+"_key").val(),};jQuery.ajax({url:dhl_ajax_object.ajax_url,data:ajax_data,method:'POST',dataType:'JSON',success:function(data){jQuery('#print_message_'+data.post.shipment_id).html(data.message)},error:function(xhr,ajaxOptions,thrownError){alert(xhr.status+': '+thrownError)},complete:function(){jQuery('.dhl-button').removeAttr('disabled','disabled');jQuery('.dhl-spinner').css({visibility:'hidden'})}})})
jQuery(document).on('click','.dhl-button-label',function(){var shipment_id=jQuery(this).attr('data-shipment-id');var url=dhl_ajax_object.ajax_url+'?action=wpdesk_dhl&dhl_action=get_label&security='+jQuery("#dhl_ajax_nonce").val();url=url+'&shipment_id='+shipment_id;url=url+'&post_id='+jQuery("input[name=post_id]").val();var count=jQuery(this).attr('data-count');url=url+'&key='+jQuery("#dhl_"+count+"_key").val(),window.open(url,'_blank')})
jQuery(document).on('change','.dhl-package-type',function(){if(jQuery(this).val()=='ENVELOPE'){jQuery(this).parent().parent().find('.dhl-weight').hide();jQuery(this).parent().parent().find('.dhl-dimensions').hide()}else{jQuery(this).parent().parent().find('.dhl-weight').show();jQuery(this).parent().parent().find('.dhl-dimensions').show()}})
jQuery(document).on('change','.dhl-product',function(){if(jQuery(this).val()=='parcelshop'){jQuery(this).parent().parent().find('div.dhl-parcelshop').show();jQuery(this).parent().parent().parent().find('.dhl-value').parent().hide();jQuery(this).closest('.dhl-package').find('.dhl_services').closest('.form-row').hide()}else{jQuery(this).parent().parent().find('div.dhl-parcelshop').hide();jQuery(this).parent().parent().parent().find('.dhl-cod').parent().parent().show();jQuery(this).parent().parent().parent().find('.dhl-value').parent().show();jQuery(this).closest('.dhl-package').find('.dhl_services').closest('.form-row').show()}})
jQuery(document).on('change','.dhl-insurance',function(){if(jQuery(this).is(':checked')){jQuery(this).closest('.dhl-package').find('.dhl-insurance-value').show()}else{jQuery(this).closest('.dhl-package').find('.dhl-insurance-value').hide()}})
jQuery(document).on('change','.dhl-cod',function(){if(jQuery(this).is(':checked')){jQuery(this).closest('.dhl-package').find('.dhl-cod-value').show()}else{jQuery(this).closest('.dhl-package').find('.dhl-cod-value').hide()}})
function dhl_init(){jQuery('.dhl-package-type').each(function(){jQuery(this).change()})
jQuery('.dhl-insurance').each(function(){jQuery(this).change()})
jQuery('.dhl-cod').each(function(){jQuery(this).change()})
jQuery('.dhl-product').each(function(){jQuery(this).change()})
jQuery('.dhl-disabled').each(function(){jQuery(this).prop('disabled',!0)})
jQuery('.wc-enhanced-select.dhl_services').selectWoo()}
dhl_init()

View File

@@ -0,0 +1,166 @@
(
function ( $ ) {
$( document ).on(
'change',
'#dhl_parcelshop',
function () {
jQuery( 'body' ).trigger( 'update_checkout' );
}
);
var dhl_select_type = dhl_checkout_js.select_type ? dhl_checkout_js.select_type : 'select2';
var dhl_lang = dhl_checkout_js.lang;
$( document ).on(
'click',
'#dhl-parcelshop-select-map',
function () {
var source = 'dhl';
var popup = $( '.js--popup-' + source );
if ( ! popup.length ) {
var map_url = new URL( dhl_checkout_js.map_url );
map_url.searchParams.append( 'options_pickup_cod', $( this ).attr( 'data-dhl_parcelshop_cod' ) );
map_url.searchParams.append( 'country', $( this ).attr( 'data-country' ) );
map_url.searchParams.append( 'postCode', $( this ).attr( 'data-postcode' ) );
map_url.searchParams.append( 'zoom', '1' );
var close_button = $( '<a></a>' ).attr( 'href', '#0' ).text( dhl_checkout_js.l10n.close_popup ).addClass( 'js--popup-close-button-' + source );
var iframe = $( '<iframe>' ).attr( 'id', source + '_map' ).attr( 'src', map_url )
popup = $( '<div></div>' ).attr( 'id', source + '_popup' ).addClass( 'js--popup-' + source ).append( close_button ).append( iframe );
$( '.js--popup-container-' + source ).html( popup );
}
popup.show();
return false;
}
);
$( document ).on(
'click',
'.js--popup-close-button-dhl',
function () {
$( '.js--popup-dhl' ).hide();
return false;
}
);
$( 'body' ).on(
'updated_checkout',
function () {
var _dhl_select = $( '#dhl_parcelshop' );
var containerClass = 'dhl-parcelshop-select-container';
var options = {
containerCssClass: containerClass,
};
if ( dhl_select_type === 'select2_ajax' ) {
let dhl_select = jQuery( '#dhl_parcelshop' );
options = {
containerCssClass: containerClass,
ajax: {
url: woocommerce_params.ajax_url,
dataType: 'json',
delay: 300,
type: 'POST',
data: function ( params ) {
return {
action: 'dhl_search_machines_via_ajax',
city: params.term,
postcode: dhl_select.data( 'postcode' ),
country: dhl_select.data( 'country' ),
security: dhl_checkout_js.ajax_nonce
};
},
processResults: function ( data ) {
return {
results: data.items,
};
},
cache: true,
},
minimumInputLength: 3,
escapeMarkup: function ( markup ) {
return markup;
},
placeholder: dhl_lang.placeholder,
language: {
inputTooShort: function ( args ) {
var remainingChars = args.minimum - args.input.length;
return dhl_lang.min_chars.replace( '%', remainingChars );
},
loadingMore: function () {
return dhl_lang.loadingMore;
},
noResults: function () {
return dhl_lang.noResults;
},
searching: function () {
return dhl_lang.searching;
},
errorLoading: function () {
return dhl_lang.errorLoading;
},
}
};
}
if ( dhl_select_type === 'select2' || dhl_select_type === 'select2_ajax' ) {
if ( $.fn.selectWoo ) {
_dhl_select.selectWoo( options );
} else if ( $.fn.select2 ) {
_dhl_select.select2( options );
}
}
}
);
}
)( jQuery );
function dhl_set_dhl_parcelshop( point ) {
var dhl_select_type = dhl_checkout_js.select_type ? dhl_checkout_js.select_type : 'select2';
let $dhl_parcelshop = jQuery( '#dhl_parcelshop' );
let country = $dhl_parcelshop.data( 'country' );
jQuery( '.js--popup-dhl' ).hide();
window.console.log( point );
let code = point.sap;
if ( 'PL' !== country ) {
code = point.sap + ':' + point.zip;
}
if ( dhl_select_type === 'select2' ) {
var exists = jQuery( "#dhl_parcelshop:has(option[value='" + code + "'])" ).length > 0;
if ( exists ) {
$dhl_parcelshop.val( code ).trigger( 'change' );
} else {
alert( dhl_checkout_js.parcelshop_not_exists );
}
} else if ( dhl_select_type === 'select2_ajax' ) {
var data = {
action: 'dhl_search_machines_via_ajax',
code: code,
postcode: point.zip,
city: point.city,
country: jQuery( '#dhl-parcelshop-select-map' ).attr( 'data-country' ),
security: dhl_checkout_js.ajax_nonce
};
jQuery.post(
woocommerce_params.ajax_url,
data,
function ( response ) {
if ( typeof response.id !== 'undefined' ) {
$dhl_parcelshop.html( '<option selected value="' + response.id + '">' + response.text + '</option>' );
jQuery( 'body' ).trigger( 'update_checkout' );
} else {
alert( dhl_checkout_js.parcelshop_not_exists );
}
}
);
}
}

View File

@@ -0,0 +1,5 @@
(function($){$(document).on('change','#dhl_parcelshop',function(){jQuery('body').trigger('update_checkout')});var dhl_select_type=dhl_checkout_js.select_type?dhl_checkout_js.select_type:'select2';var dhl_lang=dhl_checkout_js.lang;$(document).on('click','#dhl-parcelshop-select-map',function(){var source='dhl';var popup=$('.js--popup-'+source);if(!popup.length){var map_url=new URL(dhl_checkout_js.map_url);map_url.searchParams.append('options_pickup_cod',$(this).attr('data-dhl_parcelshop_cod'));map_url.searchParams.append('country',$(this).attr('data-country'));map_url.searchParams.append('postCode',$(this).attr('data-postcode'));map_url.searchParams.append('zoom','1');var close_button=$('<a></a>').attr('href','#0').text(dhl_checkout_js.l10n.close_popup).addClass('js--popup-close-button-'+source);var iframe=$('<iframe>').attr('id',source+'_map').attr('src',map_url)
popup=$('<div></div>').attr('id',source+'_popup').addClass('js--popup-'+source).append(close_button).append(iframe);$('.js--popup-container-'+source).html(popup)}
popup.show();return!1});$(document).on('click','.js--popup-close-button-dhl',function(){$('.js--popup-dhl').hide();return!1});$('body').on('updated_checkout',function(){var _dhl_select=$('#dhl_parcelshop');var containerClass='dhl-parcelshop-select-container';var options={containerCssClass:containerClass,};if(dhl_select_type==='select2_ajax'){let dhl_select=jQuery('#dhl_parcelshop');options={containerCssClass:containerClass,ajax:{url:woocommerce_params.ajax_url,dataType:'json',delay:300,type:'POST',data:function(params){return{action:'dhl_search_machines_via_ajax',city:params.term,postcode:dhl_select.data('postcode'),country:dhl_select.data('country'),security:dhl_checkout_js.ajax_nonce}},processResults:function(data){return{results:data.items,}},cache:!0,},minimumInputLength:3,escapeMarkup:function(markup){return markup},placeholder:dhl_lang.placeholder,language:{inputTooShort:function(args){var remainingChars=args.minimum-args.input.length;return dhl_lang.min_chars.replace('%',remainingChars)},loadingMore:function(){return dhl_lang.loadingMore},noResults:function(){return dhl_lang.noResults},searching:function(){return dhl_lang.searching},errorLoading:function(){return dhl_lang.errorLoading},}}}
if(dhl_select_type==='select2'||dhl_select_type==='select2_ajax'){if($.fn.selectWoo){_dhl_select.selectWoo(options)}else if($.fn.select2){_dhl_select.select2(options)}}})})(jQuery);function dhl_set_dhl_parcelshop(point){var dhl_select_type=dhl_checkout_js.select_type?dhl_checkout_js.select_type:'select2';let $dhl_parcelshop=jQuery('#dhl_parcelshop');let country=$dhl_parcelshop.data('country');jQuery('.js--popup-dhl').hide();window.console.log(point);let code=point.sap;if('PL'!==country){code=point.sap+':'+point.zip}
if(dhl_select_type==='select2'){var exists=jQuery("#dhl_parcelshop:has(option[value='"+code+"'])").length>0;if(exists){$dhl_parcelshop.val(code).trigger('change')}else{alert(dhl_checkout_js.parcelshop_not_exists)}}else if(dhl_select_type==='select2_ajax'){var data={action:'dhl_search_machines_via_ajax',code:code,postcode:point.zip,city:point.city,country:jQuery('#dhl-parcelshop-select-map').attr('data-country'),security:dhl_checkout_js.ajax_nonce};jQuery.post(woocommerce_params.ajax_url,data,function(response){if(typeof response.id!=='undefined'){$dhl_parcelshop.html('<option selected value="'+response.id+'">'+response.text+'</option>');jQuery('body').trigger('update_checkout')}else{alert(dhl_checkout_js.parcelshop_not_exists)}})}}

View File

@@ -0,0 +1 @@
// i18n support