Jump to content

Problem with discounts (urgent help required)


andy91

Recommended Posts

Hi I am using 1.3.1.1, This is an old project and one of our developers implemented a hack to give a discount of 5% for orders between 250 and 500 and 7% between 500 and 1000 and 15% for orders over 1000.

 

As far as I can tell he altered Classes\Cart.php and altered the getOrderTotal function with the following code:

 

if ($order_total >= 250 AND $order_total < 500){
  $order_total2 = 0.95 * $order_total; /* For a purchase between 250 and 500, 5% discount */
	    $discount_total = $order_total - $order_total2;
	    $order_total = $order_total2;
	    echo $discount_total;

  }
 if ($order_total >= 500 AND $order_total < 1000){
  $order_total = 0.93 * $order_total; /* For a purchase between 500 and 1000, 7% discount */
  $discount_total = 0.07 * $order_total;
  }
 if ($order_total >= 1000){
  $order_total = 0.85 * $order_total; /* For a purchase over 1000, 15% discount */
  $discount_total = 0.15 * $order_total;
  }
 if ($type == 5) return $shipping_fees;
 if ($type == 6) return $wrapping_fees;
 if ($type == 3) $order_total += $shipping_fees + $wrapping_fees;
 if ($order_total < 0 AND $type != 2) return 0;


    if($type==8){ return Tools::ps_round(floatval($discount_total), 2); }

 return Tools::ps_round(floatval($order_total), 2);

 

The problem is this: The discount amount shown is not correct but the amount taken off the total price is. Therefore the discount amount is being altered somewhere else in the code and Iv no idea where?

 

The calculations in the above code is correct and I have echo'd out $discount_total; and it shows the correct discount amount yet when it is shown in the cart the amount has been altered.

 

Anybody got any ideas on this? Its driving me nuts. I am an intermediate level php developer but Iv never used prestashop and dont really no how the system works.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...