You are here

function uc_product_uc_product_class in Ubercart 7.3

Implements hook_uc_product_class().

File

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

Code

function uc_product_uc_product_class($pcid, $op) {
  switch ($op) {
    case 'insert':
      db_update('node_type')
        ->fields(array(
        'base' => 'uc_product',
        'custom' => 0,
      ))
        ->condition('type', $pcid)
        ->execute();
      $result = db_query("SELECT n.vid, n.nid FROM {node} n LEFT JOIN {uc_products} p ON n.vid = p.vid WHERE n.type = :pcid AND p.vid IS NULL", array(
        ':pcid' => $pcid,
      ));
      foreach ($result as $node) {
        $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;
  }
}