diff --git a/assets/js/frontend/geolocation.js b/assets/js/frontend/geolocation.js index 78efb10e699..680974b8df7 100644 --- a/assets/js/frontend/geolocation.js +++ b/assets/js/frontend/geolocation.js @@ -40,7 +40,7 @@ jQuery( function( $ ) { } }; - if ( '1' !== wc_geolocation_params.is_checkout ) { + if ( '1' !== wc_geolocation_params.is_checkout && '1' !== wc_geolocation_params.is_cart && '1' !== wc_geolocation_params.is_account_page ) { $.ajax( $geolocate_customer ); } diff --git a/includes/class-wc-cache-helper.php b/includes/class-wc-cache-helper.php index 92b5606d1e6..47274f42340 100644 --- a/includes/class-wc-cache-helper.php +++ b/includes/class-wc-cache-helper.php @@ -45,7 +45,7 @@ class WC_Cache_Helper { * This prevents caching of the wrong data for this request. */ public static function geolocation_ajax_redirect() { - if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && ! is_checkout() && ! is_ajax() ) { + if ( 'geolocation_ajax' === get_option( 'woocommerce_default_customer_address' ) && ! is_checkout() && ! is_cart() && ! is_account_page() && ! is_ajax() && empty( $_POST ) ) { $location_hash = self::geolocation_ajax_get_location_hash(); $current_hash = isset( $_GET['v'] ) ? wc_clean( $_GET['v'] ) : ''; if ( empty( $current_hash ) || $current_hash !== $location_hash ) { diff --git a/includes/class-wc-frontend-scripts.php b/includes/class-wc-frontend-scripts.php index 730ec5b6b95..62d803e75bd 100644 --- a/includes/class-wc-frontend-scripts.php +++ b/includes/class-wc-frontend-scripts.php @@ -203,10 +203,12 @@ class WC_Frontend_Scripts { break; case 'wc-geolocation' : return array( - 'wc_ajax_url' => WC_AJAX::get_endpoint( "%%endpoint%%" ), - 'home_url' => home_url(), - 'is_checkout' => is_checkout() ? '1' : '0', - 'hash' => isset( $_GET['v'] ) ? wc_clean( $_GET['v'] ) : '' + 'wc_ajax_url' => WC_AJAX::get_endpoint( "%%endpoint%%" ), + 'home_url' => home_url(), + 'is_cart' => is_cart() ? '1' : '0', + 'is_account_page' => is_account_page() ? '1' : '0', + 'is_checkout' => is_checkout() ? '1' : '0', + 'hash' => isset( $_GET['v'] ) ? wc_clean( $_GET['v'] ) : '' ); break; case 'wc-single-product' :