You are here

private function UcAddressesAddressBook::loadDefaults in Ubercart Addresses 7

Same name and namespace in other branches
  1. 6.2 class/UcAddressesAddressBook.class.php \UcAddressesAddressBook::loadDefaults()

Loads all addresses from database when they not already loaded.

@access private

Return value

void

1 call to UcAddressesAddressBook::loadDefaults()
UcAddressesAddressBook::getDefaultAddress in class/UcAddressesAddressBook.class.php
Returns a default address.

File

class/UcAddressesAddressBook.class.php, line 849
Contains the UcAddressesAddressBook class.

Class

UcAddressesAddressBook
The address book class

Code

private function loadDefaults() {

  // Reason to skip out early.
  if ($this->defaultsLoaded) {
    return;
  }
  if ($this->allLoaded) {
    return;
  }
  if (!$this
    ->isOwned()) {
    return;
  }

  // If the performance hint is set to load all addresses,
  // load all addresses instead.
  if ($this->performanceHint == self::PERF_HINT_LOAD_ALL) {
    $this
      ->loadAll();
    return;
  }

  // Get all addresses for this user.
  $result = db_select('uc_addresses')
    ->condition('uid', $this->uid)
    ->condition(db_or()
    ->condition('default_shipping', 1)
    ->condition('default_billing', 1))
    ->fields('uc_addresses')
    ->orderBy('created', 'ASC')
    ->execute();

  // Set flag that default addresses are loaded.
  $this->defaultsLoaded = TRUE;
  $this
    ->dbResultToAddresses($result);
}