--- D:/Taf/Kalys/drupal6/sites/all/modules/ubercart/contrib/uc_discounts/uc_discounts.module	Thu Oct 30 15:37:14 2008
+++ D:/Taf/Kalys/drupal6/sites/all/modules/ubercart/contrib/uc_discounts/uc_discounts_original_d6_port.module	Thu Oct 30 14:30:48 2008
@@ -177,36 +177,13 @@
   if (isset($product_types[$node->type])) {
     switch ($op) {
       case 'load':
-				$discounts = uc_discounts_product_discount_price($node);
-        return array('discounts' => $discounts);
+        $node->discount_price = uc_currency_format(uc_discounts_product_discount_price($node), FALSE);
+        break;
       case 'view':
-				// Display the discount description
-				$default_enabled_value = variable_get('uc_product_field_enabled', array('discounts' => 'discounts'));
-				$default_weight_value = variable_get('uc_product_field_weight', array('discounts' => -2));
-				$output = '<div class="discounts">';
-				$discounts_descriptions = array();
-				foreach($node->discounts as $discount) {
-					$discounts_descriptions[] = t($discount['description']);
-				}
-				$output .= theme_item_list($discounts_descriptions);
-				$output .= '</div>';				
-
-				$node->content['discounts'] = array(
-					'#value' => $output,
-					'#access' => $default_enabled_value['discounts'],
-					'#weight' => $default_weight_value['discounts'],
-				);
-				
-				// Alter the node display price
         if (variable_get('uc_discounts_product_discount_price', 0)) {
-					$discounts_amount = 0;
-
-					foreach($node->discounts as $discount) {
-						$discounts_amount += $discount['amount'];
-					}
-					$discounted_price = $node->sell_price - $discounts_amount;
-          $node->content['display_price']['#value'] = theme('uc_product_display_price', $discounted_price);
-          $node->content['sell_price']['#value'] = theme('uc_discounts_sell_price', $node->sell_price, $discounted_price);
+          $discount_price = uc_discounts_product_discount_price($node);
+          $node->content['display_price']['#value'] = theme('uc_product_display_price', $discount_price);
+          $node->content['sell_price']['#value'] = theme('uc_discounts_sell_price', $node->sell_price, $discount_price, $a3);
         }
         break;
     }
@@ -214,48 +191,6 @@
 }
 
 /**
- * Implementation of hook_form_alter()
- **/
-function uc_discounts_form_alter(&$form, $form_state, $form_id) {
-	if($form_id == 'uc_product_field_settings_form') {
-		$default_enabled_value = variable_get('uc_product_field_enabled', array(
-			'model' => 'model',
-			'image' => 'image',
-			'display_price' => 'display_price',
-			'sell_price' => 'sell_price',
-			'add_to_cart' => 'add_to_cart',
-			'discounts' => 'discounts',
- 		));
-		$default_weight_value = variable_get('uc_product_field_weight', array(
-			'image' => -2,
-			'display_price' => -1,
-			'discounts' => -1,
-			'model' => 0,
-			'list_price' => 2,
-			'cost' => 3,
-			'sell_price' => 4,
-			'weight' => 5,
-			'dimensions' => 6,
-			'add_to_cart' => 10,
-		));
-		$form['fields']['discounts']['title'] = array(
-			'#type' => 'value',
-			'#default_value' => t('Discounts description'),
-		);
-		$form['fields']['discounts']['enabled'] = array(
-			'#type' => 'checkbox',
-			'#default_value' => $default_enabled_value['discounts'],
-		);
-		$form['fields']['discounts']['weight'] = array(
-			'#type' => 'weight',
-			'#delta' => 10,
-			'#default_value' => $default_weight_value['discounts'],
-		);
-	}
-}
-
-
-/**
  * Format the selling price conditionally including the discounted price.
  *
  * @param $price
@@ -298,12 +233,8 @@
   switch ($op) {
     case 'load':
       if (variable_get('uc_discounts_apply_stage', 'order') == 'cart') {
-				$node = node_load($item->nid);
-				$discounts_amount = 0;
-				foreach($node->discounts as $discount) {
-					$discounts_amount += $discount['amount'];
-				}
-				$item->price = $item->price - $discounts_amount;
+        $item->sell_price = $item->price;
+        $item->price = uc_discounts_product_discount_price($item);
       }
       break;
   }
@@ -687,18 +618,17 @@
         $apply_amount = $apply_callback($op, $action, $total_price, $cart_copy);
         $discount_amount += $apply_amount;
       }
-			if(!empty($discount_amount)) {
-				$apply_discounts[$discount->id] = array(
-					'description' => check_plain($discount->description),
-					'amount' => $discount_amount,
-				);
-			}
+      $apply_discounts[$discount->id] = array(
+        'description' => check_plain($discount->description),
+        'amount' => $discount_amount,
+      );
+      $total_price -= $discount_amount;
     }
   }
 
   // refresh the cart - somehow, the price modules are affecting it
   //$cart = uc_cart_get_contents(NULL, 'rebuild');
-  return $apply_discounts;
+  return $total_price;
 }
 
 /*******************************************************************************
