Skip to content

Commit

Permalink
Merge pull request #16085 from Progi1984/issue16080
Browse files Browse the repository at this point in the history
Fixed "Attempted to call an undefined method named 'formatPrice' of class 'PrestaShop\PrestaShop\Core\Localization\CLDR\Locale'"
  • Loading branch information
jolelievre committed Oct 24, 2019
2 parents 2776a60 + 693b112 commit a22f51b
Showing 1 changed file with 5 additions and 22 deletions.
27 changes: 5 additions & 22 deletions src/Adapter/Presenter/Order/OrderDetailLazyArray.php
Expand Up @@ -29,12 +29,11 @@
use Cart;
use Configuration;
use Context;
use Currency;
use HistoryController;
use Order;
use PrestaShop\PrestaShop\Adapter\ContainerFinder;
use PrestaShop\PrestaShop\Adapter\Presenter\AbstractLazyArray;
use PrestaShop\PrestaShop\Core\Localization\Locale;
use PrestaShop\PrestaShop\Core\Localization\Locale\Repository as LocaleRepository;
use PrestaShopBundle\Translation\TranslatorComponent;
use PrestaShopException;
use Tools;
Expand Down Expand Up @@ -63,34 +62,18 @@ class OrderDetailLazyArray extends AbstractLazyArray

/**
* OrderDetailLazyArray constructor.
*
* @param Order $order
*/
public function __construct(Order $order)
{
$this->order = $order;
$this->context = Context::getContext();
$this->translator = Context::getContext()->getTranslator();
$this->locale = $this->getCldrLocaleRepository()->getLocale(
$this->context->language->getLocale()
);
$this->locale = $this->context->getCurrentLocale();
parent::__construct();
}

/**
* @return LocaleRepository
*
* @throws \Exception
*/
protected function getCldrLocaleRepository()
{
$containerFinder = new ContainerFinder($this->context);
$container = $containerFinder->getContainer();

/** @var LocaleRepository $localeRepoCLDR */
$localeRepoCLDR = $container->get('prestashop.core.localization.cldr.locale_repository');

return $localeRepoCLDR;
}

/**
* @arrayAccess
*
Expand Down Expand Up @@ -249,7 +232,7 @@ public function getShipping()
(!$order->getTaxCalculationMethod()) ? $shipping['shipping_cost_tax_excl']
: $shipping['shipping_cost_tax_incl'];
$orderShipping[$shippingId]['shipping_cost'] =
($shippingCost > 0) ? $this->locale->formatPrice($shippingCost, (\Currency::getIsoCodeById((int) $order->id_currency)))
($shippingCost > 0) ? $this->locale->formatPrice($shippingCost, (Currency::getIsoCodeById((int) $order->id_currency)))
: $this->translator->trans('Free', array(), 'Shop.Theme.Checkout');

$tracking_line = '-';
Expand Down

0 comments on commit a22f51b

Please sign in to comment.