Use api currency service

This commit is contained in:
carmenmaymo 2023-06-15 11:39:29 +02:00
parent 013ffb5213
commit 356fc38698
No known key found for this signature in database
GPG key ID: 6023F686B0F3102E
2 changed files with 15 additions and 14 deletions

View file

@ -211,9 +211,9 @@ return array(
},
'wcgateway.notice.currency-unsupported' => static function ( ContainerInterface $container ): UnsupportedCurrencyAdminNotice {
$state = $container->get( 'onboarding.state' );
$settings = $container->get( 'wcgateway.settings' );
$shop_currency = $container->get( 'api.shop.currency' );
$supported_currencies = $container->get( 'api.supported-currencies' );
return new UnsupportedCurrencyAdminNotice( $state, $settings, $supported_currencies );
return new UnsupportedCurrencyAdminNotice( $state, $shop_currency, $supported_currencies );
},
'wcgateway.notice.dcc-without-paypal' => static function ( ContainerInterface $container ): GatewayWithoutPayPalAdminNotice {
return new GatewayWithoutPayPalAdminNotice(

View file

@ -26,12 +26,6 @@ class UnsupportedCurrencyAdminNotice {
*/
private $state;
/**
* The settings.
*
* @var ContainerInterface
*/
private $settings;
/**
* The supported currencies.
*
@ -39,16 +33,23 @@ class UnsupportedCurrencyAdminNotice {
*/
private $supported_currencies;
/**
* The shop currency.
*
* @var string
*/
private $shop_currency;
/**
* ConnectAdminNotice constructor.
*
* @param State $state The state.
* @param ContainerInterface $settings The settings.
* @param array $supported_currencies The supported currencies.
* @param State $state The state.
* @param string $shop_currency The shop currency.
* @param array $supported_currencies The supported currencies.
*/
public function __construct( State $state, ContainerInterface $settings, array $supported_currencies ) {
public function __construct( State $state, string $shop_currency, array $supported_currencies ) {
$this->state = $state;
$this->settings = $settings;
$this->shop_currency = $shop_currency;
$this->supported_currencies = $supported_currencies;
}
@ -88,7 +89,7 @@ class UnsupportedCurrencyAdminNotice {
* @return bool
*/
private function currency_supported(): bool {
$currency = get_woocommerce_currency();
$currency = $this->shop_currency;
$supported_currencies = $this->supported_currencies;
return in_array( $currency, $supported_currencies, true );
}