Hi Daniel,
There seems to be a little bug with the coupon system. Discounts are applied to the Final Total, they should be applied to the Item Price only.
For Example, If I have a product for 1.00, and shipping to 1.00, and create a coupon to give 60% off and free shipping, The total will become a negative number. Because of this.
There seems to be a little bug with the coupon system. Discounts are applied to the Final Total, they should be applied to the Item Price only.
For Example, If I have a product for 1.00, and shipping to 1.00, and create a coupon to give 60% off and free shipping, The total will become a negative number. Because of this.
I just ran in to this problem today myself, and took it upon myself to fix it. 
Open this file:
catalog/extension/calculate/coupon.php
Change all occurrences of getTotal() to getSubtotal(), save the file. I believe there should be four total, all under the calculate function.
That is the only change needed.

Open this file:
catalog/extension/calculate/coupon.php
Change all occurrences of getTotal() to getSubtotal(), save the file. I believe there should be four total, all under the calculate function.
That is the only change needed.

Hey where can i download this extension please?
i don't care about the bug cos actually it works as i want it to...

Why don't i have it in my core package? is it not in v 0.6.5? because my crapy hosting company have PHP4 on the server.
is it possible for someone to post that folder and maybe i can just add it on, or is that just wishful thinking??

Hi All,
the "getSubtotal()" workaround is wrong when a customer add products with discount and products without discount in the same cart.
Using the getSubtotal fix, for example, if I have in my shop the "product 1" that have a 10% discount, and "product 2" that have no discount and I add all the two products in my cart, I get:
product 1: 10 euro
product 2: 5 euro
subtotal: 15 euro
discount 10% = 1,5 euro
but, it is wrong, because discount must be applied only to "product 1", so the discount 10% = 1 euro.
Here, put the code to fix this problem correctly:
Edit the file catalog\extension\calculate\coupon.php, and replace the calculate() function, with this one:
the "getSubtotal()" workaround is wrong when a customer add products with discount and products without discount in the same cart.
Using the getSubtotal fix, for example, if I have in my shop the "product 1" that have a 10% discount, and "product 2" that have no discount and I add all the two products in my cart, I get:
product 1: 10 euro
product 2: 5 euro
subtotal: 15 euro
discount 10% = 1,5 euro
but, it is wrong, because discount must be applied only to "product 1", so the discount 10% = 1 euro.
Here, put the code to fix this problem correctly:
Edit the file catalog\extension\calculate\coupon.php, and replace the calculate() function, with this one:
Code: Select all
function calculate() {
$total_data = array();
if (($this->config->get('coupon_status')) && ($this->coupon->getId())) {
//apply discount only for products into coupon rule
$totalCouponProductPrice = 0;
foreach ($this->coupon->product as $result) {
$data[] = $result['product_id'];
}
foreach ($this->cart->getProducts() as $result) {
if (in_array($result['product_id'], $data)) {
$totalCouponProductPrice = $totalCouponProductPrice + ( $result['price'] * $result['quantity']);
}
}
if ($this->coupon->getDiscount($totalCouponProductPrice) > 0) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_title', $this->coupon->getName()),
'text' => '-' . $this->currency->format($this->coupon->getDiscount($totalCouponProductPrice)),
'value' => $this->coupon->getDiscount($totalCouponProductPrice)
);
$this->cart->decreaseTotal($this->coupon->getDiscount($totalCouponProductPrice));
}
if (($this->coupon->getShipping()) && ($this->cart->hasShipping())) {
$total_data[] = array(
'title' => $this->language->get('text_coupon_shipping'),
'text' => '-' . $this->currency->format($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))),
'value' => $this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method')))
);
$this->cart->decreaseTotal($this->tax->calculate($this->shipping->getCost($this->session->get('shipping_method')), $this->shipping->getTaxClassId($this->session->get('shipping_method'))));
}
}
return $total_data;
}
Who is online
Users browsing this forum: No registered users and 3 guests