Handle order project and refactor api

This commit is contained in:
Almira Krdzic
2018-09-24 21:51:55 +02:00
parent 8cc2a7c8bc
commit 11c26aeee1
32 changed files with 1408 additions and 587 deletions

View File

@@ -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) ?: '';
}