You are here

function uc_quote_get_default_shipping_address in Ubercart 8.4

Same name and namespace in other branches
  1. 5 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()

Gets a product's default shipping address.

Parameters

int $nid: A product node id.

Return value

\Drupal\uc_store\Address An address object containing the product's default shipping address, or the uc_quote's default ship_from_address if the product's is not set.

4 calls to uc_quote_get_default_shipping_address()
Package::load in shipping/uc_fulfillment/src/Package.php
Loads a package and its products.
uc_ups_quote in shipping/uc_ups/uc_ups.module
Callback for retrieving a UPS shipping quote.
UPSRateBase::packageProducts in shipping/uc_ups/src/Plugin/Ubercart/ShippingQuote/UPSRateBase.php
Organizes products into packages for shipment.
USPSRateBase::packageProducts in shipping/uc_usps/src/Plugin/Ubercart/ShippingQuote/USPSRateBase.php
Organizes products into packages for shipment.

File

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

Code

function uc_quote_get_default_shipping_address($nid) {
  $connection = \Drupal::database();
  $address = $connection
    ->query("SELECT first_name, last_name, company, street1, street2, city, zone, postal_code, country, phone FROM {uc_quote_product_locations} WHERE nid = :nid", [
    ':nid' => $nid,
  ])
    ->fetchObject('Drupal\\uc_store\\Address');
  if (empty($address)) {
    $quote_config = \Drupal::config('uc_quote.settings');
    $address = Address::create($quote_config
      ->get('ship_from_address'));
  }
  return $address;
}