顧客/ユーザーの配送先住所を見つけるには2つの方法があります
function get_user_shipping_address(){
global $user;
$default_pid =commerce_addressbook_get_default_profile_id($user->uid,'shipping');
プロファイルIDを取得したら、プロファイルをロードして顧客名と住所を取得できます
$profile_load = commerce_customer_profile_load($default_pid);
$first_line = $profile_load->commerce_customer_address['und'][0]['name_line'];
$landmark = $profile_load->commerce_customer_address['und'][0]['sub_premise'];
$postal_code = $profile_load->commerce_customer_address['und'][0]['postal_code'];
$state = $profile_load->commerce_customer_address['und'][0]['locality'];
$add[] = $first_line . ' ' . $landmark . ' ' . $postal_code . ' ' . $state;
return $add;
}
$ orderがある場合の2番目の方法
function get_default_address_of_customer_by_order_id($order) {
$order1 = commerce_order_load($order);
$shipping_id = $order1->commerce_customer_shipping['und'][0]['profile_id'];
$address = commerce_customer_profile_load($shipping_id);
$first_line = $address->commerce_customer_address['und'][0]['name_line'];
$landmark = $address->commerce_customer_address['und'][0]['sub_premise'];
$postal_code = $address->commerce_customer_address['und'][0]['postal_code'];
$state = $address->commerce_customer_address['und'][0]['locality'];
$add[] = $first_line . ' ' . $landmark . ' ' . $postal_code . ' ' . $state;
return $add;
}