Skip to content

Commit c47eb45

Browse files
committed
[Fixes #85] Separate AdminUrl and ApiUrl (Because of ApiVersion update
1 parent 9b3fe3e commit c47eb45

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

lib/ShopifyResource.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function __construct($id = null, $parentResourceUrl = '')
119119

120120
$config = ShopifySDK::$config;
121121

122-
$this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['AdminUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : '');
122+
$this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['ApiUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : '');
123123

124124
if (isset($config['AccessToken'])) {
125125
$this->httpHeaders['X-Shopify-Access-Token'] = $config['AccessToken'];

lib/ShopifySDK.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,12 +321,13 @@ public static function setAdminUrl()
321321
if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) {
322322
$apiKey = self::$config['ApiKey'];
323323
$apiPassword = self::$config['Password'];
324-
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/api/$apiVersion/";
324+
$adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/";
325325
} else {
326-
$adminUrl = "https://$shopUrl/admin/api/$apiVersion/";
326+
$adminUrl = "https://$shopUrl/admin/";
327327
}
328328

329329
self::$config['AdminUrl'] = $adminUrl;
330+
self::$config['ApiUrl'] = $adminUrl . "api/$apiVersion/";
330331

331332
return $adminUrl;
332333
}
@@ -340,6 +341,15 @@ public static function getAdminUrl() {
340341
return self::$config['AdminUrl'];
341342
}
342343

344+
/**
345+
* Get the api url of the configured shop
346+
*
347+
* @return string
348+
*/
349+
public static function getApiUrl() {
350+
return self::$config['ApiUrl'];
351+
}
352+
343353
/**
344354
* Maintain maximum 2 calls per second to the API
345355
*

0 commit comments

Comments
 (0)