Drupal - How do I get the default billing/shipping customer profile in code?

You can get default user profile address with

commerce_addressbook_get_default_profile_id($uid, $type)

Returns the default profile id for a specific uid and profile type.

@param $uid The uid of the user whose default profile id should be returned.

@param $type The type of customer profile to look up.

@return The id of the default profile if set, FALSE otherwise.

An example if want get current user shipping addresss use below code :

global $user;
$default_pid=commerce_addressbook_get_default_profile_id($user->uid,'shipping');  

Tags:

Commerce