? .svn
? 538320-uc_discount-node-type-condition.patch
? 538320-uc_discount.patch
Index: uc_discount.ca.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/uc_discount/uc_discount.ca.inc,v
retrieving revision 1.7
diff -u -p -r1.7 uc_discount.ca.inc
--- uc_discount.ca.inc	16 Apr 2010 17:07:48 -0000	1.7
+++ uc_discount.ca.inc	23 Jun 2010 19:44:22 -0000
@@ -204,6 +204,43 @@ function uc_discount_condition_node_term
   return $form;
 }
 
+/**
+ * Condition callback for node type.
+ */
+function uc_discount_condition_node_type($node, $settings) {
+  if (in_array($node->type, $settings['node_type'])) {
+    return TRUE;
+  }
+  else {
+    return FALSE;
+  }
+}
+
+/**
+ * Condition settings form for node type.
+ */
+function uc_discount_condition_node_type_form($form_state, $settings) { 
+  $form = array();
+
+  // Get all node types from uc_product's hook_node_info().
+  $types =  uc_product_node_info();
+  foreach ($types as $type => $info) {
+    $options[$type] = t($info['name']);
+  }
+  
+  $form['node_type'] = array(
+    '#type' => 'select',
+    '#title' => t('Node type'),
+    '#default_value' => $settings['node_type'],
+    '#multiple' => TRUE,
+    '#options' => $options,
+    '#description' => t('The product node is one of the selected types.'),
+  );
+  
+  return $form;
+}
+
+
 function uc_discount_condition_coupon_code($order, $settings) {
   if (isset($order->data['coupon_code'])) {
     $order->coupon_code = drupal_strtolower($order->data['coupon_code']);
