diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index ac19cd03099..6e030441fd0 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -563,8 +563,9 @@ class WC_Checkout { } if ( WC()->cart->needs_shipping() ) { + $shipping_country = WC()->customer->get_shipping_country(); - if ( empty( WC()->customer->get_shipping_country() ) ) { + if ( empty( $shipping_country ) ) { wc_add_notice( __( 'Please enter an address to continue.', 'woocommerce' ), 'error' ); } elseif ( ! in_array( WC()->customer->get_shipping_country(), array_keys( WC()->countries->get_shipping_countries() ) ) ) { wc_add_notice( sprintf( __( 'Unfortunately we do not ship %s. Please enter an alternative shipping address.', 'woocommerce' ), WC()->countries->shipping_to_prefix() . ' ' . WC()->customer->get_shipping_country() ), 'error' );