Exclude cart and account pages from geolocation

Closes #8967
This commit is contained in:
Mike Jolley 2015-09-01 15:41:05 +01:00
parent 66c0d8f009
commit f7e4bf224d
3 changed files with 8 additions and 6 deletions

View File

@ -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 );
}

View File

@ -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 ) {

View File

@ -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' :