From 35b02e1660e634e5ba33b007b1df942dc17f6ed8 Mon Sep 17 00:00:00 2001 From: Mike Jolley Date: Tue, 30 Mar 2021 16:27:09 +0100 Subject: [PATCH] Customer billing and shipping getter should merge changed data --- includes/class-wc-customer.php | 28 ++++++++++++++++++++++++++-- 1 file changed, 26 insertions(+), 2 deletions(-) diff --git a/includes/class-wc-customer.php b/includes/class-wc-customer.php index 3c5c53079f3..d66efff9d2c 100644 --- a/includes/class-wc-customer.php +++ b/includes/class-wc-customer.php @@ -449,7 +449,19 @@ class WC_Customer extends WC_Legacy_Customer { * @return array */ public function get_billing( $context = 'view' ) { - return $this->get_prop( 'billing', $context ); + $value = null; + $prop = 'billing'; + + if ( array_key_exists( $prop, $this->data ) ) { + $changes = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : array(); + $value = array_merge( $this->data[ $prop ], $changes ); + + if ( 'view' === $context ) { + $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); + } + } + + return $value; } /** @@ -580,7 +592,19 @@ class WC_Customer extends WC_Legacy_Customer { * @return array */ public function get_shipping( $context = 'view' ) { - return $this->get_prop( 'shipping', $context ); + $value = null; + $prop = 'shipping'; + + if ( array_key_exists( $prop, $this->data ) ) { + $changes = array_key_exists( $prop, $this->changes ) ? $this->changes[ $prop ] : array(); + $value = array_merge( $this->data[ $prop ], $changes ); + + if ( 'view' === $context ) { + $value = apply_filters( $this->get_hook_prefix() . $prop, $value, $this ); + } + } + + return $value; } /**