Ejemplo n.º 1
0
 /**
  * {@inheritdoc}
  */
 public function render(ResultRow $values)
 {
     $oid = $values->{$this->aliases['order_id']};
     $order = 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']);
     }
 }