--- subproducts.module	2007-11-29 13:26:03.903404000 -0800
+++ new.subproducts.module	2007-11-29 13:25:16.765753000 -0800
@@ -1112,6 +1112,18 @@ function subproducts_add_to_cart($node, 
         $options[$attribute->aid] = subproducts_surcharge_extra($attribute);
       }
     }
+    if (variable_get('add_price_to_options', 0)) {
+      $child_variations_nid = subproducts_get_child_attributes_price($node);
+      $symbol = variable_get('payment_symbol', '$');
+      foreach($variation->attributes as $attribute) {
+        if (in_array($attribute->aid, $child_variations)) {
+          $child_node = node_load($child_variations_nid[array_search($attribute->aid, $child_variations)]);
+          $options[$attribute->aid] .= " - " . $symbol . $child_node->price;
+        }
+      }
+    }
     if (!empty($options)) {
       $form['variations'][$variation->vid] = array(
         '#type' => 'select',
@@ -1746,7 +1758,7 @@ function subproducts_remove_duplicates()
  */
 function subproducts_variations_overview() {
   $ptypes = subproducts_variations_product_types();
-  $ptype = arg(4) ? arg(4) : current($ptypes);
+  $ptype = arg(3) ? arg(3) : current($ptypes);
 
   $header = array(t('Name'), t('Operations'));
 
@@ -1814,6 +1826,32 @@ function subproducts_ec_settings() {
       );
     }
   }
+  $form['subproducts_advanced'] = array(
+    '#type'           => 'fieldset',
+    '#title'          => t('Advanced'),
+    '#collapsible'    => true,
+    '#collapsed'      => false,
+  );
+    $form['subproducts_advanced']['add_price_to_options'] = array(
+      '#type'           => 'radios',
+      '#title'          => t('Add Price to Options'),
+      '#default_value'  => variable_get('add_price_to_options', 0),
+      '#options'        => array(t('Disable'), t('Enable')),
+      '#description'    => t('Add price to subproduct drop down menu options.')
+     );
+    $form['subproducts_advanced']['invisible_subproducts'] = array(
+      '#type'           => 'radios',
+      '#title'          => t('Invisible Subproducts'),
+      '#default_value'  => variable_get('invisible_subproducts', 0),
+      '#options'        => array(t('Disable'), t('Enable')),
+      '#description'    => t('Make subproducts invisible to the user (i.e. in taxonomy, search results, etc.). Purchased could only be done via parent product.'));
+    $form['subproducts_advanced']['file_product_friendly'] = array(
+      '#type'           => 'radios',
+      '#title'          => t('File Product Friendly'),
+      '#default_value'  => variable_get('file_product_friendly', 0),
+      '#options'        => array(t('Disable'), t('Enable')),
+      '#description'    => t('Change file-subproduct name and price during subproduct creation.')
+     );
   return system_settings_form($form);
 }
 
@@ -1827,7 +1865,12 @@ function subproducts_ec_settings() {
  */
 function subproducts_get_child_attributes($node) {
   $attributes = array();
-  $result = db_query("SELECT a.aid FROM {ec_product_attribute} a INNER JOIN {ec_product} p ON a.nid = p.nid INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = 1 AND p.pparent = %d", $node->nid);
+  if (variable_get('invisible_subproducts', 0)) {
+    $result = db_query("SELECT a.aid FROM {ec_product_attribute} a INNER JOIN {ec_product} p ON a.nid = p.nid INNER JOIN {node} n ON p.nid = n.nid WHERE p.pparent = %d", $node->nid);
+  }
+  else {
+    $result = db_query("SELECT a.aid FROM {ec_product_attribute} a INNER JOIN {ec_product} p ON a.nid = p.nid INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = 1 AND p.pparent = %d", $node->nid);
+  }
   while ($attribute = db_fetch_object($result)) {
     $attributes[] = $attribute->aid;
   }
@@ -1835,6 +1878,28 @@ function subproducts_get_child_attribute
 }
 
 /**
+ * Get subproducts price.
+ *
+ * @param $node
+ *   Node object representing a parent product.
+ * @return
+ *   Array of attribute ids.
+ */
+function subproducts_get_child_attributes_price($node) {
+  $attributes = array();
+  if (variable_get('invisible_subproducts', 0)) {
+    $result = db_query("SELECT a.nid FROM {ec_product_attribute} a INNER JOIN {ec_product} p ON a.nid = p.nid INNER JOIN {node} n ON p.nid = n.nid WHERE p.pparent = %d", $node->nid);
+  }
+  else {
+    $result = db_query("SELECT a.nid FROM {ec_product_attribute} a INNER JOIN {ec_product} p ON a.nid = p.nid INNER JOIN {node} n ON p.nid = n.nid WHERE n.status = 1 AND p.pparent = %d", $node->nid);
+  }
+  while ($attribute = db_fetch_object($result)) {
+    $attributes[] = $attribute->nid;
+  }
+  return $attributes;
+}
+
+/**
  * Find all the attributes of a product's subproducts' base products.
  *
  * For a product with base-type subproducts, this method finds all the
