Skip to content

Commit

Permalink
#122 Get present prices for variants by default
Browse files Browse the repository at this point in the history
  • Loading branch information
nfourtythree committed Sep 23, 2024
1 parent 41bde8d commit 03ef66b
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-WIP.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`.
11 changes: 11 additions & 0 deletions src/services/Api.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 03ef66b

Please sign in to comment.