diff --git a/lib/ShopifyResource.php b/lib/ShopifyResource.php index 4080963..1aeeb23 100644 --- a/lib/ShopifyResource.php +++ b/lib/ShopifyResource.php @@ -119,7 +119,7 @@ public function __construct($id = null, $parentResourceUrl = '') $config = ShopifySDK::$config; - $this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['AdminUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : ''); + $this->resourceUrl = ($parentResourceUrl ? $parentResourceUrl . '/' : $config['ApiUrl']) . $this->getResourcePath() . ($this->id ? '/' . $this->id : ''); if (isset($config['AccessToken'])) { $this->httpHeaders['X-Shopify-Access-Token'] = $config['AccessToken']; diff --git a/lib/ShopifySDK.php b/lib/ShopifySDK.php index ac56c86..0b6adaa 100644 --- a/lib/ShopifySDK.php +++ b/lib/ShopifySDK.php @@ -321,12 +321,13 @@ public static function setAdminUrl() if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) { $apiKey = self::$config['ApiKey']; $apiPassword = self::$config['Password']; - $adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/api/$apiVersion/"; + $adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/"; } else { - $adminUrl = "https://$shopUrl/admin/api/$apiVersion/"; + $adminUrl = "https://$shopUrl/admin/"; } self::$config['AdminUrl'] = $adminUrl; + self::$config['ApiUrl'] = $adminUrl . "api/$apiVersion/"; return $adminUrl; } @@ -340,6 +341,15 @@ public static function getAdminUrl() { return self::$config['AdminUrl']; } + /** + * Get the api url of the configured shop + * + * @return string + */ + public static function getApiUrl() { + return self::$config['ApiUrl']; + } + /** * Maintain maximum 2 calls per second to the API *