You are here

function uc_product_product_class in Ubercart 6.2

Same name and namespace in other branches
  1. 5 uc_product/uc_product.module \uc_product_product_class()

Implements hook_product_class().

File

uc_product/uc_product.module, line 1223
The product module for Ubercart.

Code

function uc_product_product_class($pcid, $op) {
  switch ($op) {
    case 'insert':
      db_query("UPDATE {node_type} SET module = 'uc_product', custom = 0 WHERE type = '%s'", $pcid);
      $result = db_query("SELECT n.vid, n.nid, p.unique_hash FROM {node} AS n LEFT JOIN {uc_products} AS p ON n.vid = p.vid WHERE n.type = '%s'", $pcid);
      while ($node = db_fetch_object($result)) {
        if (!$node->unique_hash) {
          $node->weight_units = variable_get('uc_weight_unit', 'lb');
          $node->length_units = variable_get('uc_length_unit', 'in');
          $node->pkg_qty = 1;
          $node->default_qty = 1;
          $node->shippable = 1;
          uc_product_insert($node);
        }
      }
      break;
  }
}