1 line
1.2 KiB
JavaScript
1 line
1.2 KiB
JavaScript
jQuery(function(a){var o=window.location.toString(),t=function(){wc_geolocation_params.hash&&a('a[href^="'+wc_geolocation_params.home_url+'"]:not(a[href*="v="]), a[href^="/"]:not(a[href*="v="])').each(function(){var o=a(this),t=o.attr("href"),n=t.split("#");t=(t=n[0]).indexOf("?")>0?t+"&v="+wc_geolocation_params.hash:t+"?v="+wc_geolocation_params.hash,"undefined"!=typeof n[1]&&null!==n[1]&&(t=t+"#"+n[1]),o.attr("href",t)})},n=function(a){o=o.indexOf("?v=")>0||o.indexOf("&v=")>0?o.replace(/v=[^&]+/,"v="+a):o.indexOf("?")>0?o+"&v="+a:o+"?v="+a,window.location=o},e={url:wc_geolocation_params.wc_ajax_url.toString().replace("%%endpoint%%","get_customer_location"),type:"GET",success:function(a){a.success&&a.data.hash&&a.data.hash!==wc_geolocation_params.hash&&n(a.data.hash)}};"1"===wc_geolocation_params.is_available&&(a.ajax(e),a("form").each(function(){var o=a(this),t=o.attr("method"),n=o.find('input[name="v"]').length>0;if(t&&"get"===t.toLowerCase()&&!n)o.append('<input type="hidden" name="v" value="'+wc_geolocation_params.hash+'" />');else{var e=o.attr("action");e&&(e.indexOf("?")>0?o.attr("action",e+"&v="+wc_geolocation_params.hash):o.attr("action",e+"?v="+wc_geolocation_params.hash))}}),t()),a(document.body).on("added_to_cart",function(){t()})}); |