You are here

function uc_quote_get_shipping_type in Ubercart 8.4

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

Retrieves shipping type information from the database.

Parameters

string $id_type: Type can be 'product' or 'manufacturer'.

int $id: Either the node id or term id of the object that was assigned the shipping type.

Return value

string The shipping type.

2 calls to uc_quote_get_shipping_type()
uc_product_get_shipping_type in shipping/uc_quote/uc_quote.module
Gets a product's shipping type.
uc_quote_form_node_form_alter in shipping/uc_quote/uc_quote.module
Implements hook_form_BASE_FORM_ID_alter() for node_form().

File

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

Code

function uc_quote_get_shipping_type($id_type, $id) {
  static $types = [];
  if (!isset($types[$id_type][$id])) {
    $connection = \Drupal::database();
    $types[$id_type][$id] = $connection
      ->query('SELECT shipping_type FROM {uc_quote_shipping_types} WHERE id_type = :type AND id = :id', [
      ':type' => $id_type,
      ':id' => $id,
    ])
      ->fetchField();
  }

  // @todo Shouldn't have to test here and add the small_package default -
  // there should always be a value like there was in D7.
  return isset($types[$id_type][$id]) ? $types[$id_type][$id] : 'small_package';
}