You are here

function uc_product_minmax_nodeapi in Ubercart Product Minimum & Maximum 6

Implementation of hook_nodeapi().

File

./uc_product_minmax.module, line 326
This module adds a textfield to product forms for you to enter a minimum and maximum quantity of the product that must be in the cart for it to be checked out.

Code

function uc_product_minmax_nodeapi(&$node, $op, $a3 = null, $a4 = null) {
  switch ($op) {
    case 'load':
      if (variable_get('uc_product_minmax_position', 0) == 0) {
        return (array) uc_product_minmax_feature_load($node->nid);
      }
    case 'view':
      if (variable_get('uc_product_minmax_position', 0) == 0) {
        if ($node->display_min || $node->display_max || $node->display_multiple) {
          if ($node->product_min > 1 || $node->display_multiple > 1 || $node->product_max >= 1) {
            drupal_add_css(drupal_get_path('module', 'uc_product_minmax') . '/uc_product_minmax.css', 'module', 'all', TRUE);
            $node->content['product_minmax'] = array(
              '#value' => theme('uc_product_minmax', $node->product_min, $node->pmin_multiple, $node->product_max, $node->display_min, $node->display_multiple, $node->display_max, $minmax->display_weight),
              '#weight' => !empty($node->display_weight) ? $node->display_weight : variable_get('uc_product_minmax_weight', -9),
            );
          }
        }
      }
      break;
    case 'delete':

      // Delete corresponding data from {uc_product_features} and {uc_product_minmax} tables
      db_query("DELETE FROM {uc_product_features} WHERE nid = %d AND fid='minmax'", $node->nid);
      db_query("DELETE FROM {uc_product_minmax} WHERE nid = %d", $node->nid);
      break;
  }
}