diff --git a/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderPreferences/GeneralType.php b/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderPreferences/GeneralType.php index bbc216d3d7c92..ea17185203086 100644 --- a/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderPreferences/GeneralType.php +++ b/src/PrestaShopBundle/Form/Admin/Configure/ShopParameters/OrderPreferences/GeneralType.php @@ -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; @@ -42,11 +43,6 @@ */ class GeneralType extends TranslatorAwareType { - /** - * @var string - */ - private $defaultCurrencyIsoCode; - /** * CMS pages choices for Terms Of Service. * @@ -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, [ diff --git a/src/PrestaShopBundle/Form/Admin/Improve/Shipping/Preferences/HandlingType.php b/src/PrestaShopBundle/Form/Admin/Improve/Shipping/Preferences/HandlingType.php index 5eabef9e3252e..437205abea3ca 100644 --- a/src/PrestaShopBundle/Form/Admin/Improve/Shipping/Preferences/HandlingType.php +++ b/src/PrestaShopBundle/Form/Admin/Improve/Shipping/Preferences/HandlingType.php @@ -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; @@ -46,7 +46,7 @@ class HandlingType extends TranslatorAwareType { /** - * @var CurrencyDataProvider + * @var CurrencyDataProviderInterface */ private $currencyDataProvider; @@ -59,7 +59,7 @@ public function __construct( TranslatorInterface $translator, array $locales, ConfigurationInterface $configuration, - CurrencyDataProvider $currencyDataProvider + CurrencyDataProviderInterface $currencyDataProvider ) { parent::__construct($translator, $locales); @@ -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', @@ -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' => [ diff --git a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml index e8bd1172540f3..4053e6eb434b2 100644 --- a/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml +++ b/src/PrestaShopBundle/Resources/config/services/bundle/form/form_type.yml @@ -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()' @@ -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: