Handle order project and refactor api
This commit is contained in:
@@ -34,10 +34,44 @@ class Wiaas_Customer {
|
||||
return get_user_meta($customer_id, 'profile_addresses', true) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer profile address by id
|
||||
*
|
||||
* @param int $customer_id
|
||||
* @param int $address_id
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function get_customer_profile_address($customer_id, $address_id) {
|
||||
$profile_addresses = self::get_customer_profile_addresses($customer_id);
|
||||
$index = array_search($address_id, array_column($profile_addresses, 'id'));
|
||||
if (is_numeric($index)) {
|
||||
return $profile_addresses[$index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_customer_billing_addresses($customer_id){
|
||||
return get_user_meta($customer_id, 'billing_addresses', true) ?: [];
|
||||
}
|
||||
|
||||
/**
|
||||
* Get customer billing address by id
|
||||
*
|
||||
* @param int $customer_id
|
||||
* @param int $address_id
|
||||
*
|
||||
* @return array|null
|
||||
*/
|
||||
public static function get_customer_billing_address($customer_id, $address_id) {
|
||||
$billing_addresses = self::get_customer_billing_addresses($customer_id);
|
||||
$index = array_search($address_id, array_column($billing_addresses, 'id'));
|
||||
if (is_numeric($index)) {
|
||||
return $billing_addresses[$index];
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static function get_customer_vat_code($customer_id){
|
||||
return get_user_meta($customer_id, 'vat_code', true) ?: '';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user