You are here

function uc_length_conversion in Ubercart 8.4

Same name and namespace in other branches
  1. 5 uc_store/uc_store.module \uc_length_conversion()
  2. 6.2 uc_store/uc_store.module \uc_length_conversion()
  3. 7.3 uc_store/uc_store.module \uc_length_conversion()

Gets the conversion ratio from one unit of length to another.

5 calls to uc_length_conversion()
uc_ups_quote in shipping/uc_ups/uc_ups.module
Callback for retrieving a UPS shipping quote.
uc_ups_shipment_request in shipping/uc_ups/src/Plugin/Ubercart/FulfillmentMethod/uc_ups.ship.inc
Constructs an XML shipment request.
uc_ups_shipping_quote in shipping/uc_ups/uc_ups.module
Constructs an XML quote request.
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

uc_store/uc_store.module, line 443
Contains global Ubercart functions and store administration functionality.

Code

function uc_length_conversion($from_units, $to_units = NULL) {
  if (is_null($to_units)) {
    $to_units = \Drupal::config('uc_store.settings')
      ->get('length.units');
  }
  $constant = 'UC_STORE_' . strtoupper($from_units) . '_TO_' . strtoupper($to_units);
  if (defined($constant) && ($conversion = constant($constant)) > 0) {
    return $conversion;
  }
  else {
    return 1;
  }
}