You are here

function uc_weight_conversion in Ubercart 7.3

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

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

11 calls to uc_weight_conversion()
uc_order_condition_products_weight in uc_order/uc_order.rules.inc
Checks the weight of the order's products.
uc_order_handler_field_order_weight_total::render in uc_order/views/uc_order_handler_field_order_weight_total.inc
Overrides views_handler_field::render().
uc_product_kit_insert in uc_product_kit/uc_product_kit.module
Implements hook_insert().
uc_product_kit_update in uc_product_kit/uc_product_kit.module
Implements hook_update().
uc_shipping_new_shipment in shipping/uc_shipping/uc_shipping.admin.inc
Sets up a new shipment with the chosen packages.

... See full list

File

uc_store/uc_store.module, line 1009
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 = variable_get('uc_weight_unit', 'lb');
  }
  $constant = strtoupper($from_units) . '_TO_' . strtoupper($to_units);
  if (defined($constant) && ($conversion = constant($constant)) > 0) {
    return $conversion;
  }
  else {
    return 1;
  }
}