Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

eCommerce Tycoon


You are currently viewing our eCommerce Tycoon as a guest. Please register to participate.
Login



Reply
Old 03-28-2010, 06:05 AM Currency formatting
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
Thought I would post this up in case anyway else needs it.

In Magenta 1.3 to change currency from two decimals to zero decimals:

Change

Code:
lib/Zend/Currency.php file on line 78 from
 
'precision'=>2

    to

 'precision'=>0
All your backend currency values are now in zero decimals and then

Code:
/app/code/core/Mage/Core/Model/Store.php 
around line 733 from

public function formatPrice($price, $includeContainer = true)
    {
        if ($this->getCurrentCurrency()) {
            return $this->getCurrentCurrency()->format($price, array(), $includeContainer);
        }
        return $price;
    }

to

public function formatPrice($price, $includeContainer = true)
    {
          if ($this->getCurrentCurrency()) {
            if($this->getCurrentCurrency() == "USD") {
                  return $this->getCurrentCurrency()->format($price, array('precision'=>2), $includeContainer);
            }
               else {
                  return $this->getCurrentCurrency()->format($price, array('precision'=>0), $includeContainer);
            }
          }
      return $price;
    }
If you want more currency options on the front end, just add using more conditionals.


Thats all.

Last edited by TWD; 03-29-2010 at 09:15 AM..
TWD is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-29-2010, 01:32 AM Re: Currency formatting
mikejoel's Avatar
Ultra Talker

Posts: 494
Name: mike joel ambler
Trades: 0
Interesting! Thanks for sharing!
__________________

Please login or register to view this content. Registration is FREE

Please login or register to view this content. Registration is FREE
mikejoel is offline
Reply With Quote
View Public Profile
 
Old 05-22-2010, 06:06 AM Re: Currency formatting
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
One final thing.

If you are using PayPal Standard:
go into


/app/code/core/Mage/Paypal/Model/Standard.php
and change every instance of

sprintf('%.2f', $someVariable)

into

sprintf('%.0f', $someVariable)
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is offline
Reply With Quote
View Public Profile
 
Old 05-22-2010, 06:10 AM Re: Currency formatting
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
One remaining problem with configurable products.
At first it will show the price as zero decimals but if
the visitor selects a variation, it will change the price to 2 decimals.

When I find a solution I will post it.
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE

Last edited by TWD; 05-22-2010 at 08:10 AM..
TWD is offline
Reply With Quote
View Public Profile
 
Old 06-21-2010, 10:53 PM Re: Currency formatting
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
One more thing I'll throw into the mix.

PayPal Standard will drop the Tax calculation if it doesn't understand fractional values.

To get around this change:

Code:
In app/code/core/Mage/Core/Model/Store.php
around line line 738 (Mag v1.4)

public function roundPrice($price)
    {
        
                    return round($price, 2); 
           
    }
to


Code:
public function roundPrice($price)
    {
        if ($this->getCurrentCurrency()) {
            if($this->getCurrentCurrency() == "USD") {
                  return round($price, 2);
            }
              else {
                    return round($price, 0); 
            } 
    
        }
    }
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is offline
Reply With Quote
View Public Profile
 
Old 07-22-2010, 10:39 PM Re: Currency formatting
TWD
TWD's Avatar
King Spam Talker

Posts: 1,183
Trades: 0
To fix the problem with configurable products, amend these files:

lib/js/varien/products.js

lib/Zend/locale/Data/en.xml

lib/Zend/locale/Data/ja.xml

Mage_Paypal_Model_Api_Abstract

Mage_Sales_Model_Order
__________________
RATE-MY-WEBSITE.com "Free website reviews by real web professionals"
Please login or register to view this content. Registration is FREE
TWD is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Currency formatting
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.03777 seconds with 12 queries