You are here

function uc_attribute_node_insert in Ubercart 7.3

Same name and namespace in other branches
  1. 8.4 uc_attribute/uc_attribute.module \uc_attribute_node_insert()
  2. 6.2 uc_attribute/uc_attribute.module \uc_attribute_node_insert()

Implements hook_node_insert().

File

uc_attribute/uc_attribute.module, line 377
Ubercart Attribute module.

Code

function uc_attribute_node_insert($node) {

  // Set attributes from class attributes.
  $select = db_select('uc_class_attributes', 'ca')
    ->fields('ca', array(
    'aid',
    'label',
    'ordering',
    'required',
    'display',
    'default_option',
  ))
    ->condition('pcid', $node->type);

  // SELECT $node->nid AS nid.
  $select
    ->addExpression(':nid', 'nid', array(
    ':nid' => $node->nid,
  ));
  db_insert('uc_product_attributes')
    ->from($select)
    ->execute();

  // Set options from class options.
  $select = db_select('uc_class_attribute_options', 'co')
    ->fields('co', array(
    'oid',
    'cost',
    'price',
    'weight',
    'ordering',
  ))
    ->condition('pcid', $node->type);
  $select
    ->addExpression(':nid', 'nid', array(
    ':nid' => $node->nid,
  ));
  db_insert('uc_product_options')
    ->from($select)
    ->execute();
}