1 line
1.5 KiB
JavaScript
1 line
1.5 KiB
JavaScript
jQuery(function(a){function b(){woocommerce_params.geolocation&&a("a[href^='"+woocommerce_params.home_url+"'], a[href^='/']").each(function(){var b=a(this),c=b.attr("href");c.indexOf("location=")>0||(c.indexOf("?")>0?b.attr("href",c+"&location="+woocommerce_params.geolocation):b.attr("href",c+"?location="+woocommerce_params.geolocation))})}function c(a,b){if(a!==woocommerce_params.base_country||b!==woocommerce_params.base_state){var c=window.location.toString();b&&(b=":"+b),c=c.indexOf("?")>0?c+"&location="+a+b:c+"?location="+a+b,window.location=c}}a(".woocommerce-ordering").on("change","select.orderby",function(){a(this).closest("form").submit()}),a("input.qty:not(.product-quantity input.qty)").each(function(){var b=parseFloat(a(this).attr("min"));b>=0&&parseFloat(a(this).val())<b&&a(this).val(b)});var d;try{d="sessionStorage"in window&&null!==window.sessionStorage,window.sessionStorage.setItem("wc","test"),window.sessionStorage.removeItem("wc")}catch(e){d=!1}if(d&&"1"===woocommerce_params.is_woocommerce){var f={url:woocommerce_params.wc_ajax_url+"geolocate",type:"GET",success:function(a){a.success&&a.data.country&&(sessionStorage.setItem("wc_geolocated_country",a.data.country),sessionStorage.setItem("wc_geolocated_state",a.data.state),c(a.data.country,a.data.state))}};window.location.toString().indexOf("location=")<0&&(sessionStorage.getItem("wc_geolocated_country")?c(sessionStorage.getItem("wc_geolocated_country"),sessionStorage.getItem("wc_geolocated_state")):a.ajax(f))}a(document.body).on("added_to_cart",function(){b()}),b()}); |