You are here

function uc_varprice_node_insert in UC Variable Price 7

Implements hook_node_insert().

File

./uc_varprice.module, line 155
Defines a product feature to turn any product into a variable priced product.

Code

function uc_varprice_node_insert($node) {
  if (uc_product_is_product($node)) {
    $data = variable_get('ucvp_class_def_' . $node->type, array());

    // If the product class has a default Variable Price product feature...
    if ($data) {

      // Prepare the data as if it were from a form submission.
      $data = unserialize($data);
      $data['nid'] = $node->nid;
      $data['pfid'] = '';
      $form_state = array(
        'values' => $data,
      );

      // Add the feature to the product by spoofing the normal form submission.
      uc_varprice_feature_form_submit(array(), $form_state);
    }
  }
}