I am using Magento CE 1.8.1.0. I have a requirement to use ceil on all prices/fees. I am also using product custom options.
It seems that the rounding is not done in a single place. First I modify app\code\core\Mage\Core\Model\Store.php:
public function roundPrice($price)
{
return ceil(sprintf('%.2f', $price));
}
public function formatPrice($price, $includeContainer = true)
{
if ($this->getCurrentCurrency()) {
$roundedPrice = $this->roundPrice($price);
return $this->getCurrentCurrency()->format($roundedPrice, array(), $includeContainer);
}
return $this->roundPrice($price);
}
But since I am also using catalog price rules, the special price shown in the product page is not being ceil'ed. So I modified the following: app\design\frontend\base\default\template\customoptions\catalog-product-view-options.phtml:
return Math.ceil(prPrice);
...
return Math.ceil(totalOpPrice);
Since I have product custom options, there are discounts for the product as well as for the options. I realize that the unitPrice (product price + option prices) in the shopping cart is calculated without any rounding. In my test, the unitPrice is $399.2 + $63.2 = $462.4 and in the checkout cart, after the ceiling the unitPrice is shown as $463. However I want the behavior to be that the unitPrice is calculated as: $400 + $64 = $464.
It seems that the row total for each item is calculated without any ceiling. Where should I modify the logic that calculates the row total?
The other question is that it seems that roundPrice is done all over the place. What is the best approach if I just want to change the rounding policy globally?