Währungsformatierungen im PrestaShop anpassen: Unterschied zwischen den Versionen
Aus ITwiki
Franky (Diskussion | Beiträge) (Die Seite wurde neu angelegt: „Um ein weiteres Währungsformat zum PrestaShop hinzuzufügen, müssen untenstehende Dateien bearbeitet werden. Hier wurde bereits das Format ''00.000,00X'' hin…“) |
Franky (Diskussion | Beiträge) |
||
Zeile 2: | Zeile 2: | ||
− | + | 1. '''AdminCurrencies.php''' im Ordner ''prestashop/controllers/admin/'' | |
<source lang="php"> | <source lang="php"> | ||
'query' => array( | 'query' => array( | ||
Zeile 13: | Zeile 13: | ||
), | ), | ||
</source> | </source> | ||
+ | |||
+ | 2. '''Tools.php''' im Ordner ''prestashop/classes/'' | ||
+ | <source lang="php"> | ||
+ | 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; | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | 3. '''tools.js''' im Ordner ''prestashop/js/'' | ||
+ | <source lang="javascript"> | ||
+ | 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; | ||
+ | } | ||
+ | </source> | ||
+ | |||
+ | 4. '''tools.js''' im jeweiligen Theme Ordner ''prestashop/themes/prestashop/js/'' | ||
+ | <source lang="javascript"> | ||
+ | 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; | ||
+ | } | ||
+ | </source> | ||
+ | |||
[[Kategorie:Webdesign]] | [[Kategorie:Webdesign]] |
Version vom 29. August 2013, 15:52 Uhr
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.
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 ('.$this->l('as with Danish kroner').')')
),
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;
}