Describe the bug
Function Tools::convertPrice() is deprecrated and convertPriceToCurrency() should be used instead, but this function does not exist.
/**
* Return price converted.
*
* @deprecated since 1.7.4 use convertPriceToCurrency()
*
* @param float $price Product price
* @param object|array $currency Current currency object
* @param bool $to_currency convert to currency or from currency to default currency
* @param Context $context
*
* @return float Price
*/
public static function convertPrice($price, $currency = null, $to_currency = true, Context $context = null)
{
$default_currency = (int) Configuration::get('PS_CURRENCY_DEFAULT');
if (!$context) {
$context = Context::getContext();
}
if ($currency === null) {
$currency = $context->currency;
} elseif (is_numeric($currency)) {
$currency = Currency::getCurrencyInstance($currency);
}
$c_id = (is_array($currency) ? $currency['id_currency'] : $currency->id);
$c_rate = (is_array($currency) ? $currency['conversion_rate'] : $currency->conversion_rate);
if ($c_id != $default_currency) {
if ($to_currency) {
$price *= $c_rate;
} else {
$price /= $c_rate;
}
}
return $price;
}
Additional information
PrestaShop version: 1.7.6
Hi @idnovate,
Thanks for your report.
https://github.com/PrestaShop/PrestaShop/blob/develop/classes/Tools.php#L853
I鈥檒l add this to the debug roadmap so that it鈥檚 fixed. If you have already fixed it on your end or if you think you can do it, please do send us a pull request!
Thanks!
I don't know which is the aim to replace this function. So somebody should decide to remove the @deprecated or to write new function convertPriceToCurrency()
Found the original commit introducing this wrong deprecated notice: https://github.com/PrestaShop/PrestaShop/pull/8411/files#diff-9079f61ba1c5da7f9f142723d5d42ea0R683
Most helpful comment
I don't know which is the aim to replace this function. So somebody should decide to remove the
@deprecatedor to write new functionconvertPriceToCurrency()