Do not use get_woocommerce_currency

This commit is contained in:
Alex P 2022-01-06 13:41:12 +02:00
parent 21aa8980d6
commit a432e39436
2 changed files with 7 additions and 2 deletions

View file

@ -322,7 +322,13 @@ return array(
},
'api.shop.currency' => static function ( ContainerInterface $container ) : string {
return get_woocommerce_currency();
// We use option instead of get_woocommerce_currency
// because it will not be overridden by currency switching plugins.
$currency = get_option( 'woocommerce_currency' );
if ( ! $currency ) {
return 'NO_CURRENCY'; // Unlikely to happen.
}
return $currency;
},
'api.shop.country' => static function ( ContainerInterface $container ) : string {
$location = wc_get_base_location();

View file

@ -25,7 +25,6 @@ class ModularTestCase extends TestCase
when('get_site_url')->justReturn('example.com');
when('get_bloginfo')->justReturn('My Shop');
when('wc_get_base_location')->justReturn(['country' => 'US']);
when('get_woocommerce_currency')->justReturn('USD');
when('WC')->justReturn((object) [
'session' => null,
]);