0

I've been struggling with a rounding issue lately. We have a product at 40.65. With a tax of 23% it gets up to 49.99 and rounding that up it goes to 50.

Now i want to apply some price rules. A rule of 10% discount here.

Problem is how Magento applies to discounts.

Instead of rounding up the price to 50 and then do the discount ( 50 - 50*10% = 45 ) what it does from what I understood is it applies the discount to the non-rounded price.

To the 49.99 and it calculates the discount as 4.99. After that, it applies that discount to the product getting it to 45.01 instead of 45.

I want to know if there is any way to access the part where those price rules are applied and round up the price before any catalog price rules are applied to it.

Thank you

1 Answer 1

0

From my understanding, the Mage_CatalogRule_Helper_Data::calcPriceRule() method applies the price rules to the prices:

public function calcPriceRule($actionOperator, $ruleAmount, $price)
{
    $priceRule = 0;
    switch ($actionOperator) {
        case 'to_fixed':
            $priceRule = min($ruleAmount, $price);
            break;
        case 'to_percent':
            $priceRule = $price * $ruleAmount / 100;
            break;
        case 'by_fixed':
            $priceRule = max(0, $price - $ruleAmount);
            break;
        case 'by_percent':
            $priceRule = $price * (1 - $ruleAmount / 100);
            break;
    }
    return $priceRule;
}

You could easily override the class to ensure that $price is rounded.

If you have any questions, please let me know in the comments below.

1
  • Looks like the price that it receives here is the base price and not the full after tax price. Settings -> Tax -> Apply Customer Tax -> Before Discount
    – LefterisL
    Commented Nov 30, 2016 at 11:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.