You are here

function commerce_addressbook_profile_page in Commerce Addressbook 7.3

Same name and namespace in other branches
  1. 7.2 includes/commerce_addressbook.user.inc \commerce_addressbook_profile_page()

Page callback for listing customer profiles of a certain type.

Embeds a view that shows the current default profile, and a view that shows all other profiles of the same type.

1 string reference to 'commerce_addressbook_profile_page'
commerce_addressbook_menu in ./commerce_addressbook.module
Implements hook_menu().

File

includes/commerce_addressbook.user.inc, line 169
Page callbacks and form callbacks for user addressbook pages.

Code

function commerce_addressbook_profile_page($account, $profile_type) {
  $output = '';
  $arguments = array(
    $account->uid,
    $profile_type,
  );
  $defaults_view = commerce_addressbook_retrieve_view('commerce_addressbook_defaults', 'default', $arguments);
  $list_view = commerce_addressbook_retrieve_view('commerce_addressbook', 'default', $arguments);
  if (!empty($defaults_view->result)) {
    $output .= '<div id="commerce-addressbook-' . $profile_type . '-default">' . $defaults_view
      ->render() . '</div>';
  }
  if (!empty($list_view->result)) {
    $output .= '<div id="commerce-addressbook-' . $profile_type . '-list">' . $list_view
      ->render() . '</div>';
  }
  if ($output == '') {
    return '<div class="addressbook-nodata">' . t('Your @profile_type address book is currently empty.', array(
      '@profile_type' => commerce_customer_profile_type_get_name($profile_type),
    )) . '</div>';
  }
  else {
    return $output;
  }
}