diff --git a/CHANGELOG-WIP.md b/CHANGELOG-WIP.md index 73a3e99..30ab1af 100644 --- a/CHANGELOG-WIP.md +++ b/CHANGELOG-WIP.md @@ -2,4 +2,5 @@ - Shopify now requires Craft CMS 5.3.0 or later. - Added support for selecting products in Link fields. +- Syncing products now returns presentment prices by default. ([#122](https://github.com/craftcms/shopify/issues/122)) - Added `craft\shopify\linktypes\Product`. \ No newline at end of file diff --git a/src/services/Api.php b/src/services/Api.php index d3ec133..12fb44c 100644 --- a/src/services/Api.php +++ b/src/services/Api.php @@ -12,8 +12,11 @@ use craft\helpers\App; use craft\log\MonologTarget; use craft\shopify\Plugin; +use GuzzleHttp\Client; +use Psr\Http\Client\ClientInterface; use Shopify\Auth\FileSessionStorage; use Shopify\Auth\Session; +use Shopify\Clients\HttpClientFactory; use Shopify\Clients\Rest; use Shopify\Context; use Shopify\Rest\Admin2023_10\Metafield as ShopifyMetafield; @@ -255,6 +258,14 @@ public function getSession(): ?Session logger: $webLogTarget->getLogger(), ); + Context::$HTTP_CLIENT_FACTORY = new class() extends HttpClientFactory { + public function client(): ClientInterface + { + // This is the default client, but we need to add the header for presentment prices + return new Client(['headers' => ['X-Shopify-Api-Features' => 'include-presentment-prices']]); + } + }; + $hostName = App::parseEnv($pluginSettings->hostName); $accessToken = App::parseEnv($pluginSettings->accessToken);