0

I have modified Currency file (app/code/local/Mage/Directory/Model/Currency.php) in order to show price with superscript decimals.

Everything was fine but i can't print invoices anymore. Can you help me fix that problem? Thank you!

This is what I have modified:

I have replaced this function:

public function formatTxt($price, $options = array())
{
    if (!is_numeric($price)) {
        $price = Mage::app()->getLocale()->getNumber($price);
    }
    /**
     * Fix problem with 12 000 000, 1 200 000
     *
     * %f - the argument is treated as a float, and presented as a floating-point number (locale aware).
     * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
     */
    $price = sprintf("%F", $price);
    if ($price == -0) {
        $price = 0;
    }
    return Mage::app()->getLocale()->currency($this->getCode())->toCurrency($price, $options);
}

With this one:

public function formatTxt($price, $options = array())
{
    if (!is_numeric($price)) {
        $price = Mage::app()->getLocale()->getNumber($price);
    }
    /**
     * Fix problem with 12 000 000, 1 200 000
     *
     * %f - the argument is treated as a float, and presented as a floating-point number (locale aware).
     * %F - the argument is treated as a float, and presented as a floating-point number (non-locale aware).
     */
    $price = sprintf("%0.2f", $price); 
    $parts = explode('.', $price);
    if ($price == -0) {
        $price = 0;
    }       
    echo "$parts[0]<span style = 'white-space: nowrap; font-color: #ff0000;font-size:12px'><sup> ,$parts[1] USD</sup></span>";
}
1
  • Check the file for PHP errors via CLI with php -l app/code/local/Mage/Directory/Model/Currency.php.
    – mbalparda
    Mar 6, 2015 at 15:39

1 Answer 1

0

The invoices are in PDF format, HTML code is not going to help that.

This extension works nicely:

http://www.magentocommerce.com/magento-connect/et-currency-manager.html

With it you can do things like not show '.00'. I am sure you can adapt it to your needs. Give it a go.

For the invoices it is not necessary to have fancy formatting on the prices. The above extension does not affect how those are rendered.

1
  • Thank you! Edited that extension and problem was solved :)
    – Marius
    Mar 7, 2015 at 18:41

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.