*** uc_discounts_product_class.module.old	Wed Feb 20 19:29:34 2008
--- uc_discounts_product_class.module	Wed Feb 20 19:29:54 2008
***************
*** 149,159 ****
--- 149,164 ----
  
    // make sure condition is satisfied and action is possible
    $product_price = 0;
+   $discount = 0;
    foreach ($cart as $index => $product) {
      if ($product->nid == $action->item_id || $product->type == $action->item_id) {
        $product_count += $product->qty;
        $product_price = $product->price;
        $product_found[$index] = $product->qty;
+       if (substr($action->amount, -1) == '%') {
+           $discount_percent = substr($action->amount, 0, -1) / 100;
+           $discount += (($product->price * $product->qty) * $discount_percent);
+       }
      }
    } // foreach product
  
***************
*** 162,168 ****
    }
  
    // calculate discount amount
!   if (substr($action->amount, -1) == '%') {
      $discount_percent = substr($action->amount, 0, -1) / 100;
      if ($discount_percent > 1) {
        // invalid percentage
--- 167,174 ----
    }
  
    // calculate discount amount
! /*
!  if (substr($action->amount, -1) == '%') {
      $discount_percent = substr($action->amount, 0, -1) / 100;
      if ($discount_percent > 1) {
        // invalid percentage
***************
*** 172,178 ****
      $discount = $product_price * ($discount_percent * $product_count);
    }
    else {
!     if (substr($action->amount, 0, 1) == '$') {
        $discount_amount = substr($action->amount, 1);
      }
      else {
--- 178,188 ----
      $discount = $product_price * ($discount_percent * $product_count);
    }
    else {
!  */
!  if (substr($action->amount, -1) == '%') {
!  // we already did it
!  } else {
!  if (substr($action->amount, 0, 1) == '$') {
        $discount_amount = substr($action->amount, 1);
      }
      else {
***************
*** 197,199 ****
--- 207,210 ----
  
    return $discount;
  }
+ 
