1 line
1.6 KiB
JavaScript
1 line
1.6 KiB
JavaScript
jQuery(document).ready(function(){var b;jQuery(document).on("click",".flexible-shipping-collection-point-map-selector",function(){var e=jQuery(this).attr("data-service-id");var h=jQuery(this).attr("data-select-id");var f={service_id:e,select_id:h};var g=window.top.outerHeight/2+window.top.screenY-(600/2);var d=window.top.outerWidth/2+window.top.screenX-(800/2);b=window.open(fs_collection_points_map.collection_points_map_url+"&"+jQuery.param(f),"","width=800,height=600,top="+g+",left="+d);window.addEventListener("message",function(i){if(i.origin!==window.location.origin){return false}if("get_adresses_data"===i.data.action){c(b,e,h)}if(i.data.point_id&&"select_point"===i.data.action){a(i.data.point_id,h)}},true);return false});function a(d,f){var e=jQuery("#"+f);e.val(d);e.trigger("change.select2");jQuery(document.body).trigger("update_checkout")}function c(d,f,e){var g={different_addres:jQuery("#ship-to-different-address-checkbox").prop("checked"),shipping_country:jQuery("#shipping_country").val(),shipping_address_1:jQuery("#shipping_address_1").val(),shipping_address_2:jQuery("#shipping_address_2").val(),shipping_postcode:jQuery("#shipping_postcode").val(),shipping_city:jQuery("#shipping_city").val(),billing_country:jQuery("#billing_country").val(),billing_address_1:jQuery("#billing_address_1").val(),billing_address_2:jQuery("#billing_address_2").val(),billing_postcode:jQuery("#billing_postcode").val(),billing_city:jQuery("#billing_city").val(),selected_point:jQuery("#"+e).val(),action:"fs_collection_points_"+f,security:fs_collection_points_map.ajax_nonce};d.postMessage({addresses_data:g,action:"send_address_data"},window.location.origin)}}); |