You are here

function uc_weight_conversion in Ubercart 8.4

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

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

12 calls to uc_weight_conversion()
OrderTotalWeightCondition::doEvaluate in uc_order/src/Plugin/Condition/OrderTotalWeightCondition.php
Checks the weight of the order's products.
OrderWeightTotal::render in uc_order/src/Plugin/views/field/OrderWeightTotal.php
Renders the field.
ShipmentEditForm::buildForm in shipping/uc_fulfillment/src/Form/ShipmentEditForm.php
Form constructor.
uc_order_condition_products_weight in uc_order/uc_order.rules.inc
Checks the weight of the order's products.
uc_product_kit_node_insert in uc_product_kit/uc_product_kit.module
Implements hook_node_insert().

... See full list

File

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

Code

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