nefsan Posted November 12, 2015 Share Posted November 12, 2015 Hi, I am looking the way to show my prices in the next format: $ 000.00 MXN This means that i have to show the simbol currency, the price and then the currency ISO Code on all prices in the shop. Do you have any idea how to configure prices in this format? The only way i can to configure is "$ 000.00" or "000.00 $" but not "$ 000.00 MXN" Maybe editing core files? Any help would be great. Thanks a lot. Link to comment Share on other sites More sharing options...
Rolige Posted November 12, 2015 Share Posted November 12, 2015 Yes, you need edit the class Tools.php or create an override instead. You need change the method displayPrice with the code below (this code could vary depending on your PrestaShop version): public static function displayPrice($price, $currency = null, $no_utf8 = false, Context $context = null) { if (!is_numeric($price)) return $price; if (!$context) $context = Context::getContext(); if ($currency === null) $currency = $context->currency; // if you modified this function, don't forget to modify the Javascript function formatCurrency (in tools.js) elseif (is_int($currency)) $currency = Currency::getCurrencyInstance((int)$currency); if (is_array($currency)) { $c_char = $currency['sign']; $c_format = $currency['format']; $c_decimals = (int)$currency['decimals'] * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency['blank']; $c_iso_code = $currency['iso_code']; } elseif (is_object($currency)) { $c_char = $currency->sign; $c_format = $currency->format; $c_decimals = (int)$currency->decimals * _PS_PRICE_DISPLAY_PRECISION_; $c_blank = $currency->blank; $c_iso_code = $currency->iso_code; } else return false; $blank = ($c_blank ? ' ' : ''); $ret = 0; if (($is_negative = ($price < 0))) $price *= -1; $price = Tools::ps_round($price, $c_decimals); /* * If the language is RTL and the selected currency format contains spaces as thousands separator * then the number will be printed in reverse since the space is interpreted as separating words. * To avoid this we replace the currency format containing a space with the one containing a comma (,) as thousand * separator when the language is RTL. * * TODO: This is not ideal, a currency format should probably be tied to a language, not to a currency. */ if(($c_format == 2) && ($context->language->is_rtl == 1)) { $c_format = 4; } switch ($c_format) { /* X 0,000.00 */ case 1: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', ','); break; /* 0 000,00 X*/ case 2: $ret = number_format($price, $c_decimals, ',', ' ').$blank.$c_char; break; /* X 0.000,00 */ case 3: $ret = $c_char.$blank.number_format($price, $c_decimals, ',', '.'); break; /* 0,000.00 X */ case 4: $ret = number_format($price, $c_decimals, '.', ',').$blank.$c_char; break; /* X 0'000.00 Added for the switzerland currency */ case 5: $ret = $c_char.$blank.number_format($price, $c_decimals, '.', "'"); break; } if ($is_negative) $ret = '-'.$ret; if ($no_utf8) return str_replace('€', chr(128), $ret).' '.$c_iso_code; return $ret.' '.$c_iso_code; } Link to comment Share on other sites More sharing options...
roger.edlopez Posted May 8, 2017 Share Posted May 8, 2017 (edited) Thanks, the reply above worked! Edited August 23, 2017 by roger.edlopez (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now