Jump to content

Check if currency format is correct


Recommended Posts

Hi

 

(Prestashop 1.5)

I have changed currency format to be displayed as

0.000,00X

 

please check and confirm if this is correct

it is the key 6

 

 

1. AdminCurrencies.php located in prestashop/controllers/admin/

  'query' => array(
   array('key' => 1, 'name' => 'X0,000.00 ('.$this->l('as with Dollars').')'),
   array('key' => 2, 'name' => '0 000,00X ('.$this->l('as with Euros').')'),
   array('key' => 3, 'name' => 'X0.000,00'),
   array('key' => 4, 'name' => '0,000.00X'),
   array('key' => 5, 'name' => '0 000.00X'), // Added for the switzerland currency
   array('key' => 6, 'name' => '0.000,00X ('.$this->l('as with Danish kroner').')')
  ),

2. Tools.php located in prestashop/classes/

 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;
  /* 0 000.00 X  Added for the switzerland currency */
  case 5:
$ret = number_format($price, $c_decimals, '.', ' ').$blank.$c_char;
break;
  /* 0.000,00 X */
  case 6:
$ret = number_format($price, $c_decimals, ',', '.').$blank.$c_char;
break;
 }

3. Tools.js located in prestashop/js/

function formatedNumberToFloat(price, currencyFormat, currencySign)
{
price = price.replace(currencySign, '');
if (currencyFormat == 1)
 return parseFloat(price.replace(',', '').replace(' ', ''));
else if (currencyFormat == 2)
 return parseFloat(price.replace(' ', '').replace(',', '.'));
else if (currencyFormat == 3)
 return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
else if (currencyFormat == 4)
 return parseFloat(price.replace(',', '').replace(' ', ''));
else if (currencyFormat == 6)
 return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
return price;
}

if (currencyBlank > 0)
 blank = ' ';
if (currencyFormat == 1)
 return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
if (currencyFormat == 2)
 return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
if (currencyFormat == 3)
 return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
if (currencyFormat == 4)
 return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
if (currencyFormat == 5)
 return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign);
if (currencyFormat == 6)
 return (formatNumber(price, priceDisplayPrecision, '.', ',') + blank + currencySign);
return price;
}

4. tools.js using the default theme, located in prestashop/themes/prestashop/js/

function formatedNumberToFloat(price, currencyFormat, currencySign)
{
price = price.replace(currencySign, '');
if (currencyFormat === 1)
 return parseFloat(price.replace(',', '').replace(' ', ''));
else if (currencyFormat === 2)
 return parseFloat(price.replace(' ', '').replace(',', '.'));
else if (currencyFormat === 3)
 return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
else if (currencyFormat === 4)
 return parseFloat(price.replace(',', '').replace(' ', ''));
else if (currencyFormat === 6)
 return parseFloat(price.replace('.', '').replace(' ', '').replace(',', '.'));
return price;
}





if (currencyBlank > 0)
 blank = ' ';
if (currencyFormat == 1)
 return currencySign + blank + formatNumber(price, priceDisplayPrecision, ',', '.');
if (currencyFormat == 2)
 return (formatNumber(price, priceDisplayPrecision, ' ', ',') + blank + currencySign);
if (currencyFormat == 3)
 return (currencySign + blank + formatNumber(price, priceDisplayPrecision, '.', ','));
if (currencyFormat == 4)
 return (formatNumber(price, priceDisplayPrecision, ',', '.') + blank + currencySign);
if (currencyFormat == 5)
 return (formatNumber(price, priceDisplayPrecision, ' ', '.') + blank + currencySign);
if (currencyFormat == 6)
 return (formatNumber(price, priceDisplayPrecision, '.', ',') + blank + currencySign);
return price;
}

Link to comment
Share on other sites

  • 5 months later...

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...