Customer billing and shipping getter should merge changed data

This commit is contained in:
Mike Jolley 2021-03-30 16:27:09 +01:00
parent 90d9dce1f4
commit 35b02e1660
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;
}
/**