Währungsformatierungen im PrestaShop anpassen: Unterschied zwischen den Versionen

Aus ITwiki
Wechseln zu: Navigation, Suche
Zeile 1: Zeile 1:
Um ein weiteres Währungsformat zum PrestaShop hinzuzufügen, müssen untenstehende Dateien bearbeitet werden. Hier wurde bereits das Format ''00.000,00X'' hinzugefügt.
+
Um ein weiteres Währungsformat zum PrestaShop hinzuzufügen, müssen untenstehende Dateien bearbeitet werden. Hier wurde bereits das Format ''00.000,00X'' mit dem Key 6 hinzugefügt.
  
  
Zeile 10: Zeile 10:
 
array('key' => 4, 'name' => '0,000.00X'),
 
array('key' => 4, 'name' => '0,000.00X'),
 
array('key' => 5, 'name' => '0 000.00X'), // Added for the switzerland currency
 
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').')')
+
array('key' => 6, 'name' => '0.000,00X')
 
),
 
),
 
</source>
 
</source>

Version vom 29. August 2013, 15:53 Uhr

Um ein weiteres Währungsformat zum PrestaShop hinzuzufügen, müssen untenstehende Dateien bearbeitet werden. Hier wurde bereits das Format 00.000,00X mit dem Key 6 hinzugefügt.


1. AdminCurrencies.php im Ordner 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')
	),

2. Tools.php im Ordner 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 im Ordner 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 im jeweiligen Theme Ordner 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;
}