Skip to content

Add Shopify API headers as a config to the SDK #165

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 5, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -485,6 +485,15 @@ The custom methods are specific to some resources which may not be available for
- [current()](https://help.shopify.com/api/reference/user#current)
Get the current logged-in user

### Shopify API features headers
To send `X-Shopify-Api-Features` headers while using the SDK, you can use the following:

```
$config['ShopifyApiFeatures'] = ['include-presentment-prices'];
$shopify = new PHPShopify\ShopifySDK($config);
```


## Reference
- [Shopify API Reference](https://help.shopify.com/api/reference/)

Expand Down
6 changes: 6 additions & 0 deletions lib/ShopifyResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ public function __construct($id = null, $parentResourceUrl = '')
} elseif (!isset($config['ApiKey']) || !isset($config['Password'])) {
throw new SdkException("Either AccessToken or ApiKey+Password Combination (in case of private API) is required to access the resources. Please check SDK configuration!");
}

if (isset($config['ShopifyApiFeatures'])) {
foreach($config['ShopifyApiFeatures'] as $apiFeature) {
$this->httpHeaders['X-Shopify-Api-Features'] = $apiFeature;
}
}
}

/**
Expand Down