Magento remove decimals from product page

Magento remove decimals from product page

August 20, 2026 · Illustrated author avatarBy Stefan Bogdanescu
Magento remove decimals from product page

Solving Magento Decimals Issue for Products with Custom Options

Table of Contents

  1. Understanding the Current Issue
  2. Why the Previous Changes Didn’t Work
  3. The Proper Solution for Custom Options
  4. Conclusion and Further Resources

Understanding the Current Issue

You’ve correctly identified that changing the precision settings in app\code\core\Mage\Directory\Model\Currency.php and www\app\code\core\Mage\Core\Model\Store.php can remove decimal places from most product prices in Magento. However, when a product has custom options attached, those changes don’t apply. This is because the calculation of prices with custom options involves different logic.

Why the Previous Changes Didn’t Work

The issue lies in how Magento handles products with custom options. When you add an option to a product, it creates additional calculations that are independent of the core price settings. The Mage_Catalog_Model_Product_Type_Price model is responsible for these additional calculations, and it uses different rounding rules.

The Proper Solution for Custom Options

To remove decimals from products with custom options, you need to modify the way Magento rounds option prices. Here’s how to do it:

  1. Open the file app\code\core\Mage\Catalog\Model\Product\Type\Price.php

  2. Locate the method _applyOptionsAdjustments(). It should look something like this:

private function _applyOptionsAdjustments($price)
{
    return round($price, 2);
}
  1. Replace it with the following code to remove decimals:
private function _applyOptionsAdjustments($price)
{
    return floor($price);
}
  1. Save the changes and clear your Magento cache.

Conclusion

Removing decimals from product prices in Magento, especially for products with custom options, requires a targeted approach. Changing the precision settings in core files only affects base prices, not option-specific pricing.

The solution we’ve discussed involves modifying the way Magento rounds option prices in Mage_Catalog_Model_Product_Type_Price. By changing round() to floor(), we ensure that all decimal places are removed from products with custom options.

Remember, while this solution works for removing decimals entirely, it might not be suitable if you need to retain some level of precision. In such cases, you may need a more complex pricing configuration or a custom extension.

For more advanced Magento customizations and troubleshooting, I recommend checking out the resources at Laravel Company. They provide in-depth guides on Magento development best practices.

Catalog Database Configuration Pricing

Our network