How to remove decimal price from Magento-1?

all that i found in my search is a software solution for this. I know that we can change /lib/Zend/Locale/Data/en.xml for English stores. in en.xml there was this part:

<currencyFormats> <currencyFormatLength> <currencyFormat> <pattern>#,##0.00 ¤</pattern> </currencyFormat> </currencyFormatLength> </currencyFormats> 

And the price showed in this format: 1,321.54 now, to remove the decimal part from the price, I think the only thing I need to do is change the en.xml to look like this:

 <currencyFormats> <currencyFormatLength> <currencyFormat> <pattern>#,##0 ¤</pattern> </currencyFormat> </currencyFormatLength> </currencyFormats> 

The problem is that after this change, prices are displayed as desired (format 1.132), but without the currency symbol ($). What am I missing here? Thanks in advance.


Update I'm still trying when the node template is changed to the next

 <pattern>¤ #,##0</pattern> 

prices come with a currency symbol (1,132 US dollars), but not in the desired position O_O, the requirement is to have a currency symbol on the right side, there is no left :( SO ..

+5
source share
5 answers

To change the price accuracy in magento, you will need to overwrite some basic files.

In the example below, we change the precision to 0.

1) Overwrite lib / Zend / Currency.php and change the precision around the line:

  69 protected $_options = array( 70 'position' => self::STANDARD, 71 'script' => null, 72 'format' => null, 73 'display' => self::NO_SYMBOL, 74 'precision' => 0, /*CHANGE*/ 75 'name' => null, 76 'currency' => null, 77 'symbol' => null, 78 'locale' => null, 79 'value' => 0, 80 'service' => null, 81 'tag' => 'Zend_Locale' 82 ); 

2) rewrite application / code / core /Mage/Core/Model/Store.php and change the roundPrice function:

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

3) rewrite application / code / kernel /Mage/Directory/Model/Currency.php and change the format of the function:

 public function format($price, $options=array(), $includeContainer = true, $addBrackets = false) { return $this->formatPrecision( $price, 4, $options, $includeContainer, $addBrackets); } 
+4
source

All answers here include modifying core files . This is NOT what someone should do. Either you develop a module and make these changes, or leave such core files and change prices using str_replace .

So go to theme/template/catalog/product/price.phtml and (depending on your configuration) line 209 change this:

 $_coreHelper->formatPrice($_price, true) 

in

 $without_decimals = $_coreHelper->formatPrice($_price, true); echo str_replace(".00", "", $without_decimals); 

This removes .00 from the price. It’s good that prices with other decimal places are saved. If you do not want this, you can delete everything after the period and round the number using the round() function.

Depending on the configuration, other prices may require a change (if you show prices without taxes, etc.)

+6
source

To remove the decimal part from the price, you need to change the file "code / core / Mage / Directory / Model / Currency.php"

First, instead of the line:

 return $this->formatPrecision($price, 2, $options, $includeContainer, $addBrackets); 

use:

 return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets); 

To change the position of a currency symbol, change the file "lib / Zend / Locale / Data / en.xml" to the line:

 <pattern>#,##0.00 ¤;(#,##0.00 ¤)</pattern> 

When done, remember to clear the cache.

PS To avoid any problems during the update, we strongly recommend that you implement all of the above changes through the extensions: (check the tools here: http://www.magentocommerce.com/magento-connect/catalogsearch/result/?id=&s=7&pl = 0 & eb = 0 & hp = 0 & q = currency | position & t = 1 & p = 1 )

+3
source

To remove the decimal part from the price, you need to modify the file:

1) First you need to change the accuracy around the line

Library / Zend / Currency.php

 protected $_options = array( 'position' => self::STANDARD, 'script' => null, 'format' => null, 'display' => self::NO_SYMBOL, 'precision' => 2, 'name' => null, 'currency' => null, 'symbol' => null, 'locale' => null, 'value' => 0, 'service' => null, 'tag' => 'Zend_Locale' ); 

Change = 'precision' => 2, to 'precision' => 0,

2) Second file (change roundPrice function :)

Application / Code / Kernel /Mage/Kernel/Model/Store.php

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

For

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

3) The third and last - change the format function:

Application / code / kernel /Mage/Catalog/model/Currency.php

 public function format($price, $options=array(), $includeContainer = true, $addBrackets = false) { return $this->formatPrecision( $price, 2, $options, $includeContainer, $addBrackets); } 

FROM

 public function format($price, $options=array(), $includeContainer = true, $addBrackets = false) { return $this->formatPrecision( $price, 0, $options, $includeContainer, $addBrackets); } 
+2
source

You can make another addition to the above.

Go to the PriceCurrency.php page then change the last line to

 public function round($price) { return round($price, 0); } 

then on the PriceCurrencyInterface.php page do

 const DEFAULT_PRECISION = 0; 

up.

It's all. Hope this works.

0
source

Source: https://habr.com/ru/post/1208326/


All Articles