// WAOW ! Adding change currency feature in AdminOrdersController ! It's amaizing :D Wonderful ;)
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user