You are here

function uc_atctweaks_nodeapi in UC Add to Cart Tweaks 6

Implementation of hook_nodeapi().

Summary of alterations: 1) Inserts add to cart tweak product feature on product node creation.

File

./uc_atctweaks.module, line 128
Defines a product feature to tweak the add to cart form behavior.

Code

function uc_atctweaks_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {

  // When a product node is created...
  if ($op == 'insert' && uc_product_is_product($node)) {
    $data = variable_get('ucatc_class_def_' . $node->type, array());

    // If the product class has default Add to Cart Tweaks...
    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_atctweaks_feature_form_submit(array(), $form_state);
    }
  }
}