diff --git a/modules/ppcp-api-client/services.php b/modules/ppcp-api-client/services.php index 4dcf39223..97306058f 100644 --- a/modules/ppcp-api-client/services.php +++ b/modules/ppcp-api-client/services.php @@ -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(); diff --git a/tests/PHPUnit/ModularTestCase.php b/tests/PHPUnit/ModularTestCase.php index 9756108ef..de3858c19 100644 --- a/tests/PHPUnit/ModularTestCase.php +++ b/tests/PHPUnit/ModularTestCase.php @@ -26,7 +26,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, ]);