Merge pull request #10341 from JeroenSormani/checkout-fields-value

Use real checkout fields for getting value
This commit is contained in:
Mike Jolley 2016-02-15 13:30:24 +00:00
commit e4e4a854c2
1 changed files with 12 additions and 8 deletions

View File

@ -765,9 +765,11 @@ class WC_Checkout {
}
// Get the billing_ and shipping_ address fields
$address_fields = array_merge( WC()->countries->get_address_fields(), WC()->countries->get_address_fields( '', 'shipping_' ) );
if ( isset( $this->checkout_fields['shipping'] ) && isset( $this->checkout_fields['billing'] ) ) {
if ( is_user_logged_in() && array_key_exists( $input, $address_fields ) ) {
$address_fields = array_merge( $this->checkout_fields['billing'], $this->checkout_fields['shipping'] );
if ( is_user_logged_in() && is_array( $address_fields ) && array_key_exists( $input, $address_fields ) ) {
$current_user = wp_get_current_user();
if ( $meta = get_user_meta( $current_user->ID, $input, true ) ) {
@ -779,6 +781,8 @@ class WC_Checkout {
}
}
}
switch ( $input ) {
case 'billing_country' :
return apply_filters( 'default_checkout_country', WC()->customer->get_country() ? WC()->customer->get_country() : WC()->countries->get_base_country(), 'billing' );