Files
torebki-fabiola.pl/wp-content/plugins/woocommerce-dpd/assets/js/checkout.js
2026-03-05 13:07:40 +01:00

48 lines
1.3 KiB
JavaScript

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 );