From 67adc818148e4319f4cddc79b09d14f345d74134 Mon Sep 17 00:00:00 2001 From: JeroenSormani Date: Fri, 12 Feb 2016 13:51:08 +0100 Subject: [PATCH] Use real checkout fields for getting value --- includes/class-wc-checkout.php | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/includes/class-wc-checkout.php b/includes/class-wc-checkout.php index 51fb97bdee1..7f99fef889b 100644 --- a/includes/class-wc-checkout.php +++ b/includes/class-wc-checkout.php @@ -765,18 +765,22 @@ 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 ) ) { - $current_user = wp_get_current_user(); + $address_fields = array_merge( $this->checkout_fields['billing'], $this->checkout_fields['shipping'] ); - if ( $meta = get_user_meta( $current_user->ID, $input, true ) ) { - return $meta; + 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 ) ) { + return $meta; + } + + if ( $input == 'billing_email' ) { + return $current_user->user_email; + } } - if ( $input == 'billing_email' ) { - return $current_user->user_email; - } } switch ( $input ) {