You are here

private function UcAddressesAddressBook::loadDefaults in Ubercart Addresses 6.2

Same name and namespace in other branches
  1. 7 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 843
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_query("SELECT * FROM {uc_addresses} WHERE uid = %d AND (default_shipping = 1 OR default_billing = 1) ORDER BY created", $this->uid);
  if ($result === FALSE) {
    throw new UcAddressesDbException(t('Failed to read from database table uc_addresses'));
  }

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