Merge pull request #29538 from woocommerce/fix/address-prop-updating

Customer billing and shipping getters should return all address data, not just data that changed
This commit is contained in:
Claudio Sanches 2021-04-01 18:52:40 -03:00 committed by GitHub
commit f1f1429cd3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 26 additions and 2 deletions

View File

@ -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;
}
/**