Avoid using meta directly
This commit is contained in:
parent
b64d855d96
commit
2f6aaa85bb
|
@ -439,6 +439,17 @@ class WC_Customer extends WC_Legacy_Customer {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get billing.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @param string $context
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_billing( $context = 'view' ) {
|
||||||
|
return $this->get_prop( 'billing', $context );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get billing_first_name.
|
* Get billing_first_name.
|
||||||
*
|
*
|
||||||
|
@ -559,6 +570,17 @@ class WC_Customer extends WC_Legacy_Customer {
|
||||||
return $this->get_address_prop( 'phone', 'billing', $context );
|
return $this->get_address_prop( 'phone', 'billing', $context );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get shipping.
|
||||||
|
*
|
||||||
|
* @since 3.2.0
|
||||||
|
* @param string $context
|
||||||
|
* @return array
|
||||||
|
*/
|
||||||
|
public function get_shipping( $context = 'view' ) {
|
||||||
|
return $this->get_prop( 'shipping', $context );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get shipping_first_name.
|
* Get shipping_first_name.
|
||||||
*
|
*
|
||||||
|
|
|
@ -244,30 +244,18 @@ function wc_get_account_payment_methods_types() {
|
||||||
* Get account formatted address.
|
* Get account formatted address.
|
||||||
*
|
*
|
||||||
* @since 3.2.0
|
* @since 3.2.0
|
||||||
* @param string $name
|
* @param string $address_type billing or shipping.
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
function wc_get_account_formatted_address( $name ) {
|
function wc_get_account_formatted_address( $address_type ) {
|
||||||
$customer_id = get_current_user_id();
|
$getter = "get_{$address_type}";
|
||||||
$meta_keys = [
|
$customer = new WC_Customer( get_current_user_id() );
|
||||||
'first_name',
|
|
||||||
'last_name',
|
if ( is_callable( array( $customer, $getter ) ) ) {
|
||||||
'company',
|
$address = $customer->$getter();
|
||||||
'address_1',
|
unset( $address['email'], $address['tel'] );
|
||||||
'address_2',
|
|
||||||
'city',
|
|
||||||
'postcode',
|
|
||||||
'country',
|
|
||||||
];
|
|
||||||
|
|
||||||
$meta = [];
|
|
||||||
foreach ( $meta_keys as $key ) {
|
|
||||||
$meta[ $key ] = get_user_meta( $customer_id, $name . '_' . $key, true );
|
|
||||||
}
|
}
|
||||||
|
return WC()->countries->get_formatted_address( apply_filters( 'woocommerce_my_account_my_address_formatted_address', $address, $customer->get_id(), $address_type ) );
|
||||||
$address = apply_filters( 'woocommerce_my_account_my_address_formatted_address', $meta, $customer_id, $name );
|
|
||||||
|
|
||||||
return WC()->countries->get_formatted_address( $address );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -52,12 +52,10 @@ $col = 1;
|
||||||
<h3><?php echo $title; ?></h3>
|
<h3><?php echo $title; ?></h3>
|
||||||
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
|
<a href="<?php echo esc_url( wc_get_endpoint_url( 'edit-address', $name ) ); ?>" class="edit"><?php _e( 'Edit', 'woocommerce' ); ?></a>
|
||||||
</header>
|
</header>
|
||||||
<address>
|
<address><?php
|
||||||
<?php
|
|
||||||
$address = wc_get_account_formatted_address( $name );
|
$address = wc_get_account_formatted_address( $name );
|
||||||
echo $address ? $address : __( 'You have not set up this type of address yet.', 'woocommerce' );
|
echo $address ? wp_kses_post( $address ) : esc_html_e( 'You have not set up this type of address yet.', 'woocommerce' );
|
||||||
?>
|
?></address>
|
||||||
</address>
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<?php endforeach; ?>
|
<?php endforeach; ?>
|
||||||
|
|
Loading…
Reference in New Issue