Hapus presisi dari harga suatu produk


10

Seperti yang saya katakan di judul, saya ingin menghapus presisi dari harga ( 0,00 )

Saya melakukan ini:

  1. Dalam aplikasi / kode / inti / Penyihir / Direktori / Model / Currency.php

di

public function format()

aku berubah

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

untuk

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

di

public function getEscapedValue()

aku berubah

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

untuk

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

aku berubah

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

untuk

var precision = 0;
var requiredPrecision = 0;
  1. Dan di app / code / core / Mage / Core / Model / Store.php

aku berubah

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

untuk

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

Lalu saya membersihkan cache, dan mengindeks ulang Magento (yang saya versi 1.9), tetapi presisi tidak menghapus, Apakah saya kehilangan sesuatu? apa yang harus saya lakukan?


Selalu menimpa kelas inti
— Beto Castillo

Jawaban:



4

Pertanyaan lama, tetapi tidak benar-benar memiliki jawaban yang benar terprogram.

$ _product adalah model objek produk Anda.

$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)
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.