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,214 @@
jQuery(document).on('click','.dpd-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('#dpd_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('#dpd_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','.dpd-button-delete-package', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery(this).parent().remove();
})
jQuery(document).on('click','.dpd-button-delete-created', function( e ) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dpd-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dpd_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','.dpd-button-create', function(e) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dpd-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
dpd_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','.dpd-button-save', function(e) {
var count = jQuery(this).attr('data-count');
if ( typeof count != 'undefined' ) {
if (jQuery(this).attr('disabled') == 'disabled') {
return;
}
jQuery('.dpd-button').attr('disabled', 'disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dpd_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','.dpd-button-delete', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery('.dpd-button').attr('disabled','disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
dpd_ajax( 'delete_package', count );
})
jQuery(document).on('click','.dpd-button-print', function() {
if ( jQuery(this).attr('disabled') == 'disabled' ) {
return;
}
jQuery('.dpd-button').attr('disabled','disabled');
jQuery(this).parent().find('.spinner').css({visibility: 'visible'});
var count = jQuery(this).attr('data-count');
var ajax_data = {
'action' : 'wpdesk_dpd',
'dpd_action' : 'print_label',
'security' : jQuery("#dpd_ajax_nonce").val(),
'post_id' : jQuery("input[name=post_id]").val(),
'shipment_id' : jQuery(this).attr('data-shipment-id'),
'key' : jQuery("#dpd_"+count+"_key").val(),
};
jQuery.ajax({
url : dpd_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('.dpd-button').removeAttr('disabled','disabled');
jQuery('.dpd-spinner').css({visibility: 'hidden'});
}
});
})
jQuery(document).on('click','.dpd-button-label', function() {
var shipment_id = jQuery(this).attr('data-shipment-id');
var url = dpd_ajax_object.ajax_url + '?action=wpdesk_dpd&dpd_action=get_label&security=' + jQuery("#dpd_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("#dpd_"+count+"_key").val(),
window.open( url, '_blank');
})
jQuery(document).on('change','.dpd-product', function() {
})
jQuery(document).on('change','.dpd-declared_value', function() {
if ( jQuery(this).is(':checked') ) {
jQuery(this).closest('.dpd-package').find('.dpd-declared_value-value').show();
}
else {
jQuery(this).closest('.dpd-package').find('.dpd-declared_value-value').hide();
}
})
jQuery(document).on('change','.dpd-cod', function() {
if ( jQuery(this).is(':checked') ) {
jQuery(this).closest('.dpd-package').find('.dpd-cod-value').show();
}
else {
jQuery(this).closest('.dpd-package').find('.dpd-cod-value').hide();
}
})
jQuery(document).on('change','.dpd-pickup', function() {
if ( jQuery(this).is(':checked') ) {
jQuery(this).closest('.dpd-package').find('.dpd-pickup-value').show();
}
else {
jQuery(this).closest('.dpd-package').find('.dpd-pickup-value').hide();
}
})
function dpd_init() {
jQuery('.dpd-product').each(function(){
jQuery(this).change();
})
jQuery('.dpd-disabled').each(function(){
jQuery(this).prop('disabled',true);
})
jQuery('.dpd-declared_value').each(function(){
jQuery(this).change();
})
jQuery('.dpd-cod').each(function(){
jQuery(this).change();
})
jQuery('.dpd-pickup').each(function(){
jQuery(this).change();
})
}
dpd_init();

View File

@@ -0,0 +1,30 @@
jQuery(document).on('click','.dpd-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('#dpd_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('#dpd_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','.dpd-button-delete-package',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery(this).parent().remove()})
jQuery(document).on('click','.dpd-button-delete-created',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dpd-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dpd_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','.dpd-button-create',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dpd-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});dpd_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','.dpd-button-save',function(e){var count=jQuery(this).attr('data-count');if(typeof count!='undefined'){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dpd-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dpd_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','.dpd-button-delete',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dpd-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');dpd_ajax('delete_package',count)})
jQuery(document).on('click','.dpd-button-print',function(){if(jQuery(this).attr('disabled')=='disabled'){return}
jQuery('.dpd-button').attr('disabled','disabled');jQuery(this).parent().find('.spinner').css({visibility:'visible'});var count=jQuery(this).attr('data-count');var ajax_data={'action':'wpdesk_dpd','dpd_action':'print_label','security':jQuery("#dpd_ajax_nonce").val(),'post_id':jQuery("input[name=post_id]").val(),'shipment_id':jQuery(this).attr('data-shipment-id'),'key':jQuery("#dpd_"+count+"_key").val(),};jQuery.ajax({url:dpd_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('.dpd-button').removeAttr('disabled','disabled');jQuery('.dpd-spinner').css({visibility:'hidden'})}})})
jQuery(document).on('click','.dpd-button-label',function(){var shipment_id=jQuery(this).attr('data-shipment-id');var url=dpd_ajax_object.ajax_url+'?action=wpdesk_dpd&dpd_action=get_label&security='+jQuery("#dpd_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("#dpd_"+count+"_key").val(),window.open(url,'_blank')})
jQuery(document).on('change','.dpd-product',function(){})
jQuery(document).on('change','.dpd-declared_value',function(){if(jQuery(this).is(':checked')){jQuery(this).closest('.dpd-package').find('.dpd-declared_value-value').show()}else{jQuery(this).closest('.dpd-package').find('.dpd-declared_value-value').hide()}})
jQuery(document).on('change','.dpd-cod',function(){if(jQuery(this).is(':checked')){jQuery(this).closest('.dpd-package').find('.dpd-cod-value').show()}else{jQuery(this).closest('.dpd-package').find('.dpd-cod-value').hide()}})
jQuery(document).on('change','.dpd-pickup',function(){if(jQuery(this).is(':checked')){jQuery(this).closest('.dpd-package').find('.dpd-pickup-value').show()}else{jQuery(this).closest('.dpd-package').find('.dpd-pickup-value').hide()}})
function dpd_init(){jQuery('.dpd-product').each(function(){jQuery(this).change()})
jQuery('.dpd-disabled').each(function(){jQuery(this).prop('disabled',!0)})
jQuery('.dpd-declared_value').each(function(){jQuery(this).change()})
jQuery('.dpd-cod').each(function(){jQuery(this).change()})
jQuery('.dpd-pickup').each(function(){jQuery(this).change()})}
dpd_init()

View File

@@ -0,0 +1,47 @@
function dpd_choosen_point( pointID ) {
jQuery( '.js--popup-dpd' ).hide();
let $field = jQuery( '#dpd_pickup_point_id' );
if ( $field.find( 'option[value="' + pointID + '"]' ).length === 0 ) {
$field.append( '<option value="' + pointID + '">' + pointID + '</option>' );
$field.val( pointID );
} else {
$field.val( pointID ).trigger( 'change' );
}
jQuery('body').trigger('update_checkout');
}
( function ( $ ) {
var body = $( 'body' );
body.on(
'click',
'.js--choose-point-dpd',
function () {
var popup = $( '.js--popup-dpd' );
if ( ! popup.length ) {
var map_url = new URL( __jsDpdVars.map_url );
map_url.searchParams.append( 'direct_delivery_cod', $( this ).attr( 'data-direct_delivery_cod' ) );
var close_button = $( '<a></a>' ).attr( 'href', '#0' ).text( __jsDpdVars.l10n.close_popup ).addClass( 'js--popup-close-button-dpd' );
var iframe = $( '<iframe>' ).attr( 'id', 'dpd_map' ).attr( 'src', map_url )
popup = $( '<div></div>' ).attr( 'id', 'dpd_popup' ).addClass( 'js--popup-dpd' ).append( close_button ).append( iframe );
$( '.js--popup-container-dpd' ).html( popup );
}
popup.show();
return false;
}
);
body.on(
'click',
'.js--popup-close-button-dpd',
function () {
$( '.js--popup-dpd' ).hide();
return false;
}
);
} )( jQuery );

View File

@@ -0,0 +1,4 @@
function dpd_choosen_point(pointID){jQuery('.js--popup-dpd').hide();let $field=jQuery('#dpd_pickup_point_id');if($field.find('option[value="'+pointID+'"]').length===0){$field.append('<option value="'+pointID+'">'+pointID+'</option>');$field.val(pointID)}else{$field.val(pointID).trigger('change')}
jQuery('body').trigger('update_checkout')}(function($){var body=$('body');body.on('click','.js--choose-point-dpd',function(){var popup=$('.js--popup-dpd');if(!popup.length){var map_url=new URL(__jsDpdVars.map_url);map_url.searchParams.append('direct_delivery_cod',$(this).attr('data-direct_delivery_cod'));var close_button=$('<a></a>').attr('href','#0').text(__jsDpdVars.l10n.close_popup).addClass('js--popup-close-button-dpd');var iframe=$('<iframe>').attr('id','dpd_map').attr('src',map_url)
popup=$('<div></div>').attr('id','dpd_popup').addClass('js--popup-dpd').append(close_button).append(iframe);$('.js--popup-container-dpd').html(popup)}
popup.show();return!1});body.on('click','.js--popup-close-button-dpd',function(){$('.js--popup-dpd').hide();return!1})})(jQuery)