製品の価格から精度を取り除く


10

タイトルで言ったように、価格から精度を取り除きたい(.00

私はこれらをしました:

  1. ではアプリ/コード/コア/メイジ/ディレクトリ/モデル/ Currency.php

public function format()

私が変更され

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

 return $this->formatPrecision($price, 0, $options, $includeContainer, $addBrackets);
  1. では/app/code/core/Mage/Adminhtml/Block/Catalog/Product/Helper/Form/Price.php

public function getEscapedValue()

私が変更され

 return number_format($value, 2, null, '');

 return number_format($value, 0, null, '');
  1. ではJS / varien / js.js

私が変更され

var precision = isNaN(format.precision = Math.abs(format.precision)) ? 2 : format.precision;
var requiredPrecision = isNaN(format.requiredPrecision = Math.abs(format.requiredPrecision)) ? 2 : format.requiredPrecision;

var precision = 0;
var requiredPrecision = 0;
  1. そしてapp / code / core / Mage / Core / Model / Store.php

私が変更され

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

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

次に、キャッシュをクリアし、Magento(iバージョン1.9)のインデックスを再作成しましたが、精度は削除されませんでした。何か不足していますか?私は何をすべきか?


常にコアクラスをオーバーライドする
Beto Castillo

回答:


13

あなたはhttp://www.magentocommerce.com/magento-connect/et-currency-manager.htmlを見てみることができます私はそれを使ったことはありませんが、小数点以下の桁数などを管理できることがわかります

「とにかくセントが必要なのは誰ですか?セントなしで価格を表示できます。例:49.00の代わりに49を表示しますが、49.99は変更しません。」

さらに無料です:-)


請求書の金額は変わりますか?
M.Elwan 2017

4

古い質問ですが、プログラムによる正しい答えはありません。

$ _productは、製品オブジェクトモデルです。

$price = ($_product->getFinalPrice() != 0) ? $_product->getFinalPrice()
            : $_product->getPrice();
        if ($round) {
            $store = Mage::app()->getStore(null);
            $currency = $store->getCurrentCurrency();
            return $currency->formatPrecision($price, 0, array(), true, false);
        }
        return Mage::helper('core')->currencyByStore($price)
弊社のサイトを使用することにより、あなたは弊社のクッキーポリシーおよびプライバシーポリシーを読み、理解したものとみなされます。
Licensed under cc by-sa 3.0 with attribution required.