Retrieve shop currency later to avoid early caching in service

This commit is contained in:
Alex P. 2024-10-03 10:10:50 +03:00
parent b3d457d64a
commit f85df4718a
No known key found for this signature in database
GPG key ID: 54487A734A204D71
24 changed files with 187 additions and 136 deletions

View file

@ -36,7 +36,7 @@ return array(
return new ApmApplies(
$container->get( 'googlepay.supported-countries' ),
$container->get( 'googlepay.supported-currencies' ),
$container->get( 'api.shop.currency' ),
$container->get( 'api.shop.currency.getter' ),
$container->get( 'api.shop.country' )
);
},

View file

@ -10,6 +10,8 @@ declare(strict_types=1);
namespace WooCommerce\PayPalCommerce\Googlepay\Helper;
use WooCommerce\PayPalCommerce\ApiClient\Helper\CurrencyGetter;
/**
* Class ApmApplies
*/
@ -30,11 +32,11 @@ class ApmApplies {
private $allowed_currencies;
/**
* 3-letter currency code of the shop.
* The getter of the 3-letter currency code of the shop.
*
* @var string
* @var CurrencyGetter
*/
private $currency;
private CurrencyGetter $currency;
/**
* 2-letter country code of the shop.
@ -46,15 +48,15 @@ class ApmApplies {
/**
* DccApplies constructor.
*
* @param array $allowed_countries The list of which countries can be used for GooglePay.
* @param array $allowed_currencies The list of which currencies can be used for GooglePay.
* @param string $currency 3-letter currency code of the shop.
* @param string $country 2-letter country code of the shop.
* @param array $allowed_countries The list of which countries can be used for GooglePay.
* @param array $allowed_currencies The list of which currencies can be used for GooglePay.
* @param CurrencyGetter $currency The getter of the 3-letter currency code of the shop.
* @param string $country 2-letter country code of the shop.
*/
public function __construct(
array $allowed_countries,
array $allowed_currencies,
string $currency,
CurrencyGetter $currency,
string $country
) {
$this->allowed_countries = $allowed_countries;
@ -78,7 +80,7 @@ class ApmApplies {
* @return bool
*/
public function for_currency(): bool {
return in_array( $this->currency, $this->allowed_currencies, true );
return in_array( $this->currency->get(), $this->allowed_currencies, true );
}
}