Fix up standards #7939

This commit is contained in:
Mike Jolley 2015-06-17 13:59:04 +01:00
parent 33c298fea7
commit 9886a805df
3 changed files with 8 additions and 8 deletions

View File

@ -26,7 +26,7 @@ jQuery( function( $ ) {
function add_geolocation_to_links() {
if ( woocommerce_params.geolocation ) {
$( "a[href*='" + woocommerce_params.home_url + "'], a[href*='/']").each( function() {
$( "a[href^='" + woocommerce_params.home_url + "'], a[href^='/']").each( function() {
var $this = $(this);
var href = $this.attr('href');
@ -43,7 +43,7 @@ jQuery( function( $ ) {
}
}
if ( $supports_html5_storage && woocommerce_params.is_woocommerce == 1 ) {
if ( $supports_html5_storage && '1' === woocommerce_params.is_woocommerce ) {
// Redirect based on geolocation to get around static caching
var $geolocate_customer = {
@ -60,7 +60,7 @@ jQuery( function( $ ) {
function handle_geolocation_redirect( country, state ) {
// Redirect if not base location
if ( country != woocommerce_params.base_country || state != woocommerce_params.base_state ) {
if ( country !== woocommerce_params.base_country || state !== woocommerce_params.base_state ) {
var this_page = window.location.toString();
if ( state ) {
@ -76,15 +76,15 @@ jQuery( function( $ ) {
}
if ( window.location.toString().indexOf( 'location=' ) < 0 ) {
if ( sessionStorage.getItem( 'wc_geolocated_country' ) ) {
if ( ! sessionStorage.getItem( 'wc_geolocated_country' ) ) {
$.ajax( $geolocate_customer );
} else if ( sessionStorage.getItem( 'wc_geolocated_country' ) ) {
} else {
handle_geolocation_redirect( sessionStorage.getItem( 'wc_geolocated_country' ), sessionStorage.getItem( 'wc_geolocated_state' ) );
}
}
}
$( document.body ).on('added_to_cart', function() {
$( document.body ).on( 'added_to_cart', function() {
add_geolocation_to_links();
});

View File

@ -1 +1 @@
jQuery(function(a){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 b={url:wc_cart_fragments_params.wc_ajax_url+"geolocate",type:"GET",success:function(a){console.log(a),console.log(":)");var b=window.location.toString();b.indexOf("location=")<0&&(b=b+"?location="+a.country,window.location=b)}};a.ajax(b)});
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()});

View File

@ -313,7 +313,7 @@ class WC_Customer {
$tax_based_on = 'base';
}
if ( $tax_based_on == 'base' || ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && empty( $_GET['location'] ) && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WOOCOMMERCE_CART' ) ) ) {
if ( 'base' === $tax_based_on || ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && empty( $_GET['location'] ) && ! defined( 'WOOCOMMERCE_CHECKOUT' ) && ! defined( 'WOOCOMMERCE_CART' ) ) ) {
$default = wc_get_base_location();
$country = $default['country'];