Skip to content

Commit

Permalink
Fix typo carrier
Browse files Browse the repository at this point in the history
  • Loading branch information
FabienPapet committed Feb 7, 2023
1 parent f2c279e commit a9224d5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 20 deletions.
Expand Up @@ -27,6 +27,7 @@
namespace PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences;

use PrestaShop\PrestaShop\Core\ConfigurationInterface;
use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface;
use PrestaShopBundle\Form\Admin\Type\MoneyWithSuffixType;
use PrestaShopBundle\Form\Admin\Type\MultistoreConfigurationType;
use PrestaShopBundle\Form\Admin\Type\SwitchType;
Expand All @@ -42,11 +43,6 @@
*/
class GeneralType extends TranslatorAwareType
{
/**
* @var string
*/
private $defaultCurrencyIsoCode;

/**
* CMS pages choices for Terms Of Service.
*
Expand All @@ -59,25 +55,30 @@ class GeneralType extends TranslatorAwareType
*/
private $configuration;

/**
* @var CurrencyDataProviderInterface
*/
private $currencyDataProvider;

public function __construct(
TranslatorInterface $translator,
array $locales,
CurrencyDataProviderInterface $currencyDataProvider,
ConfigurationInterface $configuration,
$defaultCurrencyIsoCode,
array $tosCmsChoices
) {
parent::__construct($translator, $locales);

$this->defaultCurrencyIsoCode = $defaultCurrencyIsoCode;
$this->tosCmsChoices = $tosCmsChoices;
$this->configuration = $configuration;
$this->currencyDataProvider = $currencyDataProvider;
}

public function buildForm(FormBuilderInterface $builder, array $options)
{
$configuration = $this->configuration;
$isMultishippingEnabled = (bool) $configuration->get('PS_ALLOW_MULTISHIPPING');
$currencyIsoCode = $this->defaultCurrencyIsoCode;
$currencyIsoCode = $this->currencyDataProvider->getDefaultCurrencyIsoCode();

$builder
->add('enable_final_summary', SwitchType::class, [
Expand Down
Expand Up @@ -26,8 +26,8 @@

namespace PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences;

use PrestaShop\PrestaShop\Adapter\Currency\CurrencyDataProvider;
use PrestaShop\PrestaShop\Core\ConfigurationInterface;
use PrestaShop\PrestaShop\Core\Currency\CurrencyDataProviderInterface;
use PrestaShopBundle\Form\Admin\Type\MoneyWithSuffixType;
use PrestaShopBundle\Form\Admin\Type\MultistoreConfigurationType;
use PrestaShopBundle\Form\Admin\Type\TranslatorAwareType;
Expand All @@ -46,7 +46,7 @@
class HandlingType extends TranslatorAwareType
{
/**
* @var CurrencyDataProvider
* @var CurrencyDataProviderInterface
*/
private $currencyDataProvider;

Expand All @@ -59,7 +59,7 @@ public function __construct(
TranslatorInterface $translator,
array $locales,
ConfigurationInterface $configuration,
CurrencyDataProvider $currencyDataProvider
CurrencyDataProviderInterface $currencyDataProvider
) {
parent::__construct($translator, $locales);

Expand All @@ -69,13 +69,12 @@ public function __construct(

public function buildForm(FormBuilderInterface $builder, array $options)
{
$defaultCurrencyId = (int) $this->configuration->get('PS_CURRENCY_DEFAULT');
$defaultCurrency = $this->currencyDataProvider->getCurrencyById($defaultCurrencyId);
$defaultCurrencyIsoCode = $this->currencyDataProvider->getDefaultCurrencyIsoCode();
$weightUnit = $this->configuration->get('PS_WEIGHT_UNIT');

$builder
->add('shipping_handling_charges', MoneyWithSuffixType::class, [
'currency' => $defaultCurrency->iso_code,
'currency' => $defaultCurrencyIsoCode,
'suffix' => $this->trans('(tax excl.)', 'Admin.Global'),
'required' => false,
'empty_data' => '0',
Expand All @@ -90,7 +89,7 @@ public function buildForm(FormBuilderInterface $builder, array $options)
'multistore_configuration_key' => 'PS_SHIPPING_HANDLING',
])
->add('free_shipping_price', MoneyType::class, [
'currency' => $defaultCurrency->iso_code,
'currency' => $defaultCurrencyIsoCode,
'required' => false,
'empty_data' => '0',
'constraints' => [
Expand Down
Expand Up @@ -173,12 +173,9 @@ services:
abstract: true

PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\HandlingType:
arguments:
$currencyDataProvider: '@prestashop.adapter.data_provider.currency'

PrestaShopBundle\Form\Admin\Improve\Shipping\Preferences\CarrierOptionsType:
arguments:
$carriers: '@=service("prestashop.adapter.data_provider.carrier").getOrderWayChoices()'
$carriers: '@=service("prestashop.adapter.data_provider.carrier").getActiveCarriersChoices()'
$orderByChoices: '@=service("prestashop.adapter.data_provider.carrier").getOrderByChoices()'
$orderWayChoices: '@=service("prestashop.adapter.data_provider.carrier").getOrderWayChoices()'

Expand All @@ -190,7 +187,6 @@ services:

PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GeneralType:
arguments:
$defaultCurrencyIsoCode: '@=service("prestashop.adapter.data_provider.currency").getDefaultCurrencyIsoCode()'
$tosCmsChoices: '@=service("prestashop.adapter.data_provider.cms").getCmsChoices()'

PrestaShopBundle\Form\Admin\Configure\ShopParameters\OrderPreferences\GiftOptionsType:
Expand Down

0 comments on commit a9224d5

Please sign in to comment.