Ada 2 Cara untuk Menemukan Alamat pengiriman Pelanggan / pengguna-
function get_user_shipping_address(){
global $user;
$default_pid =commerce_addressbook_get_default_profile_id($user->uid,'shipping');
Setelah mendapatkan id profil Anda dapat memuat profil dan mendapatkan nama & Alamat pelanggan
$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;
}
cara kedua jika Anda memiliki $ order
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;
}