rejig the order of loading address. Closes #2161.

This commit is contained in:
Mike Jolley 2013-01-07 15:58:19 +00:00
parent 1ef704140e
commit 0786e7f9fc
1 changed files with 30 additions and 23 deletions

View File

@ -751,41 +751,48 @@ class WC_Checkout {
return esc_attr( $_POST[ $input ] );
} elseif ( is_user_logged_in() ) {
if ( $meta = get_user_meta( get_current_user_id(), $input, true ) )
return $meta;
$current_user = wp_get_current_user();
if ( $input == "billing_email" )
return $current_user->user_email;
} else {
$default_billing_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_country()) ? $woocommerce->customer->get_country() : $woocommerce->countries->get_base_country());
if ( is_user_logged_in() ) {
$default_shipping_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_shipping_country()) ? $woocommerce->customer->get_shipping_country() : $woocommerce->countries->get_base_country());
$current_user = wp_get_current_user();
if ( $woocommerce->customer->has_calculated_shipping() ) {
$default_billing_state = apply_filters('default_checkout_state', $woocommerce->customer->get_state());
$default_shipping_state = apply_filters('default_checkout_state', $woocommerce->customer->get_shipping_state());
} else {
$default_billing_state = apply_filters('default_checkout_state', '');
$default_shipping_state = apply_filters('default_checkout_state', '');
if ( $meta = get_user_meta( get_current_user_id(), $input, true ) )
return $meta;
if ( $input == "billing_email" )
return $current_user->user_email;
}
if ( $input == "billing_country" ) return $default_billing_country;
$default_billing_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_country()) ? $woocommerce->customer->get_country() : $woocommerce->countries->get_base_country());
if ( $input == "billing_state" ) return $default_billing_state;
$default_shipping_country = apply_filters('default_checkout_country', ($woocommerce->customer->get_shipping_country()) ? $woocommerce->customer->get_shipping_country() : $woocommerce->countries->get_base_country());
if ( $input == "billing_postcode" ) return ($woocommerce->customer->get_postcode()) ? $woocommerce->customer->get_postcode() : '';
if ( $woocommerce->customer->has_calculated_shipping() ) {
$default_billing_state = apply_filters('default_checkout_state', $woocommerce->customer->get_state());
$default_shipping_state = apply_filters('default_checkout_state', $woocommerce->customer->get_shipping_state());
} else {
$default_billing_state = apply_filters('default_checkout_state', '');
$default_shipping_state = apply_filters('default_checkout_state', '');
}
if ( $input == "shipping_country" ) return $default_shipping_country;
if ( $input == "billing_country" )
return $default_billing_country;
if ( $input == "shipping_state" ) return $default_shipping_state;
if ( $input == "billing_state" )
return $default_billing_state;
if ( $input == "shipping_postcode" ) return ($woocommerce->customer->get_shipping_postcode()) ? $woocommerce->customer->get_shipping_postcode() : '';
if ( $input == "billing_postcode" )
return $woocommerce->customer->get_postcode() ? $woocommerce->customer->get_postcode() : '';
if ( $input == "shipping_country" )
return $default_shipping_country;
if ( $input == "shipping_state" )
return $default_shipping_state;
if ( $input == "shipping_postcode" )
return $woocommerce->customer->get_shipping_postcode() ? $woocommerce->customer->get_shipping_postcode() : '';
}
}
}