// WAOW ! Adding change currency feature in AdminOrdersController ! It's amaizing :D Wonderful ;)

This commit is contained in:
aFolletete
2011-11-23 23:04:33 +00:00
parent 319d4b9272
commit cc1578c8b7
6 changed files with 134 additions and 76 deletions
+37
View File
@@ -463,7 +463,44 @@ class ToolsCore
return $price;
}
/**
*
* Convert amount from a currency to an other currency automatically
* @param float $amount
* @param Currency $currency_from if null we used the default currency
* @param Currency $currency_to if null we used the default currency
*/
public static function convertPriceFull($amount, Currency $currency_from = null, Currency $currency_to = null)
{
if ($currency_from == $currency_to)
return $amount;
if ($currency_from === null)
{
$currency_from = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$default_currency = $currency_from;
}
if ($currency_to === null)
{
$currency_to = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
$default_currency = $currency_to;
}
if ($currency_from->id == Configuration::get('PS_CURRENCY_DEFAULT'))
$amount *= $currency_to->conversion_rate;
else
{
if (!isset($default_currency))
$default_currency = new Currency(Configuration::get('PS_CURRENCY_DEFAULT'));
// Convert amount to default currency
$amount = Tools::ps_round($amount / $default_currency->conversion_rate, 2);
// Convert to new currency
$amount *= $currency_to->conversion_rate;
}
return Tools::ps_round($amount, 2);
}
/**
* Display date regarding to language preferences
+2 -2
View File
@@ -20,7 +20,7 @@
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 10418 $
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/
@@ -384,4 +384,4 @@ class OrderInvoiceCore extends ObjectModel
AND `id_order_invoice` = '.(int)$this->id
);
}
}
}
+1 -1
View File
@@ -20,7 +20,7 @@
*
* @author PrestaShop SA <contact@prestashop.com>
* @copyright 2007-2011 PrestaShop SA
* @version Release: $Revision: 10336 $
* @version Release: $Revision: 6844 $
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
* International Registered Trademark & Property of PrestaShop SA
*/