Search code examples
magento

Removing .00 in configurable attribute price in Magento


The currency I'm using in the Magento site I'm creating is Japanese Yen which does not have decimals in their currency. I've managed to remove it from my product page and cart.

By modifying app/code/local/Mage/Directory/Model/Currency.php inside format function like so:

$locale = Mage::app()->getLocale()->getLocaleCode();
if($locale != 'ja_JP') {
    return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets);
} else {
    return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
}

However, in the dropdown attribute I created, the decimal still shows. Like so:

White - ¥3000.00

Blue - ¥5000.00

In my dropdown attribute, how can I drop .00 at the end of the price? Also, is it possible to drop decimal for the admin without altering the database?

I've tried searching but sadly, Magento does not have a direct feature that would handle this. Or at least I haven't come across said feature.


Solution

  • Okay, so I managed to remove .00 by modifying configurable.js and product.js. It's not a direct solution but a workaround.

    For each file, I split the price string removing any decimal points(.) and numbers succeeding it by using the split function of javascript. So I added something like so:

    var a = price.split(.);
    return a[0];
    

    Using that, all the decimals have been dropped from my prices. Thanks for all your time and help.