You are here

function uc_quote_get_default_shipping_address in Ubercart 5

Same name and namespace in other branches
  1. 8.4 shipping/uc_quote/uc_quote.module \uc_quote_get_default_shipping_address()
  2. 6.2 shipping/uc_quote/uc_quote.module \uc_quote_get_default_shipping_address()
  3. 7.3 shipping/uc_quote/uc_quote.module \uc_quote_get_default_shipping_address()

Get a product's default shipping address.

Load the default shipping address of a product, it's manufacturer's, or the store's, whichever is available.

Parameters

$nid: A product node id.

Return value

An address object.

3 calls to uc_quote_get_default_shipping_address()
uc_shipping_package_load in shipping/uc_shipping/uc_shipping.module
Load a package and its products.
uc_ups_quote in shipping/uc_ups/uc_ups.module
Callback for retrieving a UPS shipping quote.
_uc_usps_package_products in shipping/uc_usps/uc_usps.module

File

shipping/uc_quote/uc_quote.module, line 946
The controller module for fulfillment modules that process physical goods.

Code

function uc_quote_get_default_shipping_address($nid) {
  $address = db_fetch_object(db_query("SELECT first_name, last_name, company, street1, street2, city, zone, postal_code, country, phone FROM {uc_quote_product_locations} WHERE nid = %d", $nid));
  if (empty($address)) {
    if (module_exists('uc_manufacturer')) {
      $manufacturer = uc_product_get_manufacturer($nid);
      $address = db_fetch_object(db_query("SELECT first_name, last_name, company, street1, street2, city, zone, postal_code, country, phone FROM {uc_quote_manufacturer_locations} WHERE tid = %d", $manufacturer->tid));
    }
    if (empty($address)) {
      $address = variable_get('uc_quote_store_default_address', new stdClass());
    }
  }
  return $address;
}