function uc_order_handler_field_order_weight_total::render in Ubercart 7.3
Overrides views_handler_field::render().
Overrides uc_product_handler_field_weight::render
File
- uc_order/
views/ uc_order_handler_field_order_weight_total.inc, line 45 - Total weight field handler.
Class
- uc_order_handler_field_order_weight_total
- Field handler: displays a weight multiplied by the quantity.
Code
function render($values) {
$oid = $values->{$this->aliases['order_id']};
$order = uc_order_load($oid);
$total = 0;
foreach ($order->products as $product) {
$unit_conversion = uc_weight_conversion($product->weight_units, $this->options['weight_units']);
$total += $product->qty * $product->weight * $unit_conversion;
}
$this->field_alias = 'order_weight';
$values->{$this->field_alias} = $total;
if ($this->options['format'] == 'numeric') {
return parent::render($values);
}
if ($this->options['format'] == 'uc_weight') {
return uc_weight_format($values->{$this->field_alias}, $this->options['weight_units']);
}
}