You are here

function uc_attribute_node_insert in Ubercart 6.2

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

Add default attributes to a product node.

2 calls to uc_attribute_node_insert()
uc_attribute_nodeapi in uc_attribute/uc_attribute.module
Implements hook_nodeapi().
uc_attribute_node_reset in uc_attribute/uc_attribute.module
Reset attributes to class defaults for a product node.

File

uc_attribute/uc_attribute.module, line 405

Code

function uc_attribute_node_insert($node) {
  switch ($GLOBALS['db_type']) {
    case 'mysqli':
    case 'mysql':
      db_query("INSERT IGNORE INTO {uc_product_attributes} (nid, aid, label, ordering, required, display, default_option) SELECT %d, aid, label, ordering, required, display, default_option FROM {uc_class_attributes} WHERE pcid = '%s'", $node->nid, $node->type);
      db_query("INSERT IGNORE INTO {uc_product_options} (nid, oid, cost, price, weight, ordering) SELECT %d, oid, cost, price, weight, ordering FROM {uc_class_attribute_options} WHERE pcid = '%s'", $node->nid, $node->type);
      break;
    case 'pgsql':
      db_query("INSERT INTO {uc_product_attributes} (nid, aid, label, ordering, required, display, default_option) SELECT %d, aid, label, ordering, required, display, default_option FROM {uc_class_attributes} WHERE pcid = '%s'", $node->nid, $node->type);
      db_query("INSERT INTO {uc_product_options} (nid, oid, cost, price, weight, ordering) SELECT %d, oid, cost, price, weight, ordering FROM {uc_class_attribute_options} WHERE pcid = '%s'", $node->nid, $node->type);
      break;
  }
}