You are here

public function UcOrderProductController::save in Ubercart 7.3

Overrides EntityAPIController::save().

Overrides EntityAPIController::save

File

uc_order/uc_order.controller.inc, line 113
Contains controller classes for uc_order and uc_order_product entities.

Class

UcOrderProductController
Controller class for the uc_order_product entity.

Code

public function save($product, DatabaseTransaction $transaction = NULL) {

  // Product kits, particularly, shouldn't actually be added to an order,
  // but instead they cause other products to be added.
  if (isset($product->skip_save) && $product->skip_save == TRUE) {
    return;
  }
  if (empty($product->weight_units)) {
    if (empty($product->nid)) {
      $product->weight_units = variable_get('uc_weight_unit', 'lb');
    }
    else {
      $units = db_query("SELECT weight_units FROM {node} n JOIN {uc_products} p ON n.vid = p.vid WHERE n.nid = :nid", array(
        ':nid' => $product->nid,
      ))
        ->fetchField();
      $product->weight_units = empty($units) ? variable_get('uc_weight_unit', 'lb') : $units;
    }
  }
  return parent::save($product, $transaction);
}