├── .editorconfig ├── .env.example ├── .gitattributes ├── .gitignore ├── LICENSE.md ├── README.md ├── composer.json ├── composer.lock ├── example └── content │ ├── collections │ └── shopify.collections.txt │ └── products │ └── shopify.products.txt ├── index.php ├── src ├── KirbyShopify.php ├── blueprints │ ├── shopify.collection.yml │ ├── shopify.collections.yml │ ├── shopify.product.yml │ └── shopify.products.yml ├── helpers.php ├── models │ ├── shopify.collection.php │ ├── shopify.collections.php │ ├── shopify.product.php │ └── shopify.products.php └── snippets │ └── product.structured-data.php └── vendor ├── autoload.php ├── composer ├── ClassLoader.php ├── autoload_classmap.php ├── autoload_files.php ├── autoload_namespaces.php ├── autoload_psr4.php ├── autoload_real.php └── autoload_static.php ├── phpclassic └── php-shopify │ ├── composer.lock │ └── lib │ ├── AbandonedCheckout.php │ ├── ApplicationCharge.php │ ├── Article.php │ ├── Asset.php │ ├── AuthHelper.php │ ├── Balance.php │ ├── Batch.php │ ├── Blog.php │ ├── CarrierService.php │ ├── Collect.php │ ├── Collection.php │ ├── Comment.php │ ├── Country.php │ ├── CurlRequest.php │ ├── CurlResponse.php │ ├── Currency.php │ ├── CustomCollection.php │ ├── Customer.php │ ├── CustomerAddress.php │ ├── CustomerSavedSearch.php │ ├── Discount.php │ ├── DiscountCode.php │ ├── Dispute.php │ ├── DraftOrder.php │ ├── Event.php │ ├── Exception │ ├── ApiException.php │ ├── CurlException.php │ ├── ResourceRateLimitException.php │ └── SdkException.php │ ├── Fulfillment.php │ ├── FulfillmentEvent.php │ ├── FulfillmentService.php │ ├── GiftCard.php │ ├── GraphQL.php │ ├── HttpRequestGraphQL.php │ ├── HttpRequestJson.php │ ├── InventoryItem.php │ ├── InventoryLevel.php │ ├── Location.php │ ├── Metafield.php │ ├── Multipass.php │ ├── Order.php │ ├── OrderRisk.php │ ├── Page.php │ ├── Payouts.php │ ├── Policy.php │ ├── PriceRule.php │ ├── Product.php │ ├── ProductImage.php │ ├── ProductListing.php │ ├── ProductVariant.php │ ├── Province.php │ ├── RecurringApplicationCharge.php │ ├── Redirect.php │ ├── Refund.php │ ├── Report.php │ ├── ScriptTag.php │ ├── ShippingZone.php │ ├── Shop.php │ ├── ShopifyPayment.php │ ├── ShopifyResource.php │ ├── ShopifySDK.php │ ├── SmartCollection.php │ ├── TenderTransaction.php │ ├── Theme.php │ ├── Transaction.php │ ├── Transactions.php │ ├── UsageCharge.php │ ├── User.php │ └── Webhook.php ├── symfony └── polyfill-ctype │ ├── Ctype.php │ ├── bootstrap.php │ └── bootstrap80.php └── vlucas └── phpdotenv └── src ├── Dotenv.php ├── Exception ├── ExceptionInterface.php ├── InvalidCallbackException.php ├── InvalidFileException.php ├── InvalidPathException.php └── ValidationException.php ├── Loader.php ├── Parser.php └── Validator.php /.editorconfig: -------------------------------------------------------------------------------- 1 | # This file is for unifying the coding style for different editors and IDEs 2 | # editorconfig.org 3 | 4 | [*] 5 | charset = utf-8 6 | indent_style = space 7 | indent_size = 2 8 | end_of_line = lf 9 | insert_final_newline = true 10 | trim_trailing_whitespace = true 11 | 12 | [*.php] 13 | indent_size = 4 14 | 15 | [*.md,*.txt] 16 | trim_trailing_whitespace = false 17 | insert_final_newline = false 18 | 19 | [composer.json] 20 | indent_size = 4 21 | -------------------------------------------------------------------------------- /.env.example: -------------------------------------------------------------------------------- 1 | SHOP_URL="shop.myshopify.com" 2 | API_KEY="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 3 | API_PASSWORD="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 4 | SHOPIFY_APP_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 5 | ACCESS_TOKEN="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" 6 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Note: You need to uncomment the lines you want to use; the other lines can be deleted 2 | 3 | # Git 4 | # .gitattributes export-ignore 5 | # .gitignore export-ignore 6 | 7 | # Tests 8 | # .coveralls.yml export-ignore 9 | # .travis.yml export-ignore 10 | # phpunit.xml.dist export-ignore 11 | # tests/ export-ignore -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OS files 2 | .DS_Store 3 | 4 | # npm modules 5 | /node_modules 6 | .env 7 | 8 | # files of Composer dependencies that are not needed for the plugin 9 | /vendor/**/.* 10 | /vendor/**/*.json 11 | /vendor/**/*.txt 12 | /vendor/**/*.md 13 | /vendor/**/*.yml 14 | /vendor/**/*.yaml 15 | /vendor/**/*.xml 16 | /vendor/**/*.dist 17 | /vendor/**/readme.php 18 | /vendor/**/LICENSE 19 | /vendor/**/COPYING 20 | /vendor/**/VERSION 21 | /vendor/**/docs/* 22 | /vendor/**/example/* 23 | /vendor/**/examples/* 24 | /vendor/**/test/* 25 | /vendor/**/tests/* 26 | /vendor/**/php4/* 27 | /vendor/getkirby/composer-installer -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Kirby 3 Shopify Plugin 2 | 3 | **** 4 | 5 | ## Installation 6 | 7 | ### Download 8 | 9 | Download and copy this repository to `/site/plugins/kirby-shopify`. 10 | 11 | ### Git submodule 12 | 13 | ``` 14 | git submodule add https://github.com/tristantbg/kirby-shopify.git site/plugins/kirby-shopify 15 | ``` 16 | 17 | ### Composer 18 | 19 | ``` 20 | composer require tristantbg/kirby-shopify 21 | ``` 22 | 23 | ## Setup 24 | 25 | Set your `.env` file inside the plugin folder using the `.env.example` one with your Storefront credentials. 26 | Add manually a page called `products` with the template `shopify.products` in the content folder. (like shown in "example") 27 | Add manually a page called `collections` with the template `shopify.collections` in the content folder. (like shown in "example") 28 | 29 | ``` 30 | API_KEY= 1 31 | API_PASSWORD= 2 32 | SHOPIFY_APP_SECRET= 3 33 | ACCESS_TOKEN= 4 (Useless) 34 | ``` 35 | 36 | Capture d’écran 2023-05-15 à 16 43 12 37 | 38 | ![kirby-shopify screen-3](https://user-images.githubusercontent.com/4832038/136786285-67ada112-52e8-45d5-b9ff-9724a8aca172.png) 39 | 40 | 41 | ## Make Shopify update your Kirby products list 42 | 43 | Set a Shopify webhook for "Product create", "Product update", "Product delete" with value: 44 | ``` 45 | https://your-kirby.com/kirby-shopify/api/cache/products/clear 46 | ``` 47 | 48 | Set a Shopify webhook for "Collection create", "Collection update", "Collection delete" with value: 49 | ``` 50 | https://your-kirby.com/kirby-shopify/api/cache/collections/clear 51 | ``` 52 | At the end of https://xxx.myshopify.com/admin/settings/notifications 53 | 54 | (The webhook is verified for security reasons: https://help.shopify.com/en/api/getting-started/webhooks#verify-webhook) 55 | Add the webhook HMAC signed key to your `.env` file under the `SHOPIFY_APP_SECRET` key 56 | 57 | ## Frontend 58 | 59 | An easy way would be to use Shopify Buy Button on top of Kirby to take care of the cart. 60 | You can either display everything with it or choose to use Kirby to display the element more customly. 61 | 62 | Shop JS script: 63 | 64 | ``` 65 | const Shop = { 66 | scriptURL: 'https://sdks.shopifycdn.com/buy-button/latest/buy-button-storefront.min.js', 67 | options: { 68 | "product": { 69 | iframe: false, 70 | variantId: "all", 71 | events: { 72 | afterRender: _ => {} 73 | }, 74 | text: { 75 | button: 'Add to cart' 76 | }, 77 | "contents": { 78 | "img": true, 79 | "title": true, 80 | "imgWithCarousel": false, 81 | "variantTitle": false, 82 | "description": true, 83 | "buttonWithQuantity": false, 84 | "quantity": false 85 | } 86 | }, 87 | "cart": { 88 | iframe: true, 89 | startOpen: true, 90 | popup: true, 91 | "contents": { 92 | "button": true 93 | } 94 | }, 95 | "lineItem": {}, 96 | "toggle": { 97 | iframe: false, 98 | "contents": { 99 | "title": true, 100 | "icon": false 101 | }, 102 | "text": { 103 | title: "Cart" 104 | }, 105 | }, 106 | "modalProduct": { 107 | "contents": { 108 | "img": false, 109 | "imgWithCarousel": true, 110 | "variantTitle": false, 111 | "buttonWithQuantity": true, 112 | "button": false, 113 | "quantity": false 114 | }, 115 | }, 116 | "productSet": {} 117 | }, 118 | init: _ => { 119 | if (window.ShopifyBuy) { 120 | if (window.ShopifyBuy.UI) { 121 | Shop.ShopifyBuyInit(); 122 | } else { 123 | loadScript(); 124 | } 125 | } else { 126 | loadScript(); 127 | } 128 | 129 | function loadScript() { 130 | var script = document.createElement('script'); 131 | script.async = true; 132 | script.src = Shop.scriptURL; 133 | (document.getElementsByTagName('head')[0] || document.getElementsByTagName('body')[0]).appendChild(script); 134 | script.onload = Shop.ShopifyBuyInit; 135 | } 136 | }, 137 | ShopifyBuyInit: _ => { 138 | Shop.client = ShopifyBuy.buildClient({ 139 | domain: 'xxx.myshopify.com', 140 | storefrontAccessToken: 'xxxxxxx', 141 | appId: '6', 142 | }); 143 | const items = document.querySelectorAll('[data-product]') 144 | items.forEach(el => { 145 | Shop.createButton(el.dataset.product) 146 | }) 147 | }, 148 | createButton: id => { 149 | const node = document.getElementById('product-component-' + id) 150 | ShopifyBuy.UI.onReady(Shop.client).then(function(ui) { 151 | ui.createComponent('product', { 152 | id: [id], 153 | node: node, 154 | moneyFormat: '{{amount_with_comma_separator}} €', 155 | options: Shop.options 156 | }); 157 | }); 158 | } 159 | } 160 | 161 | export default Shop; 162 | ``` 163 | 164 | `shopify.product` template: 165 | 166 | ``` 167 | // Creates product in JS 168 |
169 | 170 | // Display values with Kirby if you want 171 | 172 | yourCustomField() ?> 173 | shopifyPrice() ?> 174 | shopifyDescriptionHTML() ?> 175 | shopifyType() ?> 176 | shopifyVendor() ?> 177 | 178 | shopifyTags()->split(',') as $key => $tag): ?> 179 | 180 | 181 | ``` 182 | 183 | ## Resize thumbnails 184 | 185 | You can resize thumbnails directly from Shopify CDN using this field method and the Shopify `img_url` attribute. 186 | https://help.shopify.com/en/themes/liquid/filters/url-filters#img_url 187 | ``` 188 | 189 | ``` 190 | 191 | ## The toProduct() method 192 | 193 | When you try to access a product through a Collection, you need to use the `$productInCollection->toProduct()` method in order to get the original product page which is in the `page('products')`. Because you only want one product page with custom fields. 194 | 195 | ## Options 196 | 197 | WIP 198 | 199 | ## API 200 | 201 | ``` 202 | \KirbyShopify\App::init() 203 | \KirbyShopify\App::getProducts() 204 | \KirbyShopify\App::clearCache() 205 | ``` 206 | 207 | ## License 208 | 209 | MIT 210 | 211 | ## Credits 212 | 213 | - [Tristan Bagot](https://github.com/tristantbg) 214 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tristantbg/kirby-shopify", 3 | "description": "Display products on your own site and integrate the checkout process with your Shopify shop", 4 | "type": "kirby-plugin", 5 | "license": "MIT", 6 | "version": "1.3.7", 7 | "authors": [ 8 | { 9 | "name": "Tristan Bagot", 10 | "email": "hello@tristanbagot.com" 11 | } 12 | ], 13 | "require": { 14 | "getkirby/composer-installer": "^1.1", 15 | "vlucas/phpdotenv": "^2.4", 16 | "phpclassic/php-shopify": "^1.0" 17 | }, 18 | "config": { 19 | "optimize-autoloader": true 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "dc18a4451a679ab49bc6699ac55c8cf0", 8 | "packages": [ 9 | { 10 | "name": "getkirby/composer-installer", 11 | "version": "1.2.1", 12 | "source": { 13 | "type": "git", 14 | "url": "https://github.com/getkirby/composer-installer.git", 15 | "reference": "c98ece30bfba45be7ce457e1102d1b169d922f3d" 16 | }, 17 | "dist": { 18 | "type": "zip", 19 | "url": "https://api.github.com/repos/getkirby/composer-installer/zipball/c98ece30bfba45be7ce457e1102d1b169d922f3d", 20 | "reference": "c98ece30bfba45be7ce457e1102d1b169d922f3d", 21 | "shasum": "" 22 | }, 23 | "require": { 24 | "composer-plugin-api": "^1.0 || ^2.0" 25 | }, 26 | "require-dev": { 27 | "composer/composer": "^1.8 || ^2.0" 28 | }, 29 | "type": "composer-plugin", 30 | "extra": { 31 | "class": "Kirby\\ComposerInstaller\\Plugin" 32 | }, 33 | "autoload": { 34 | "psr-4": { 35 | "Kirby\\": "src/" 36 | } 37 | }, 38 | "notification-url": "https://packagist.org/downloads/", 39 | "license": [ 40 | "MIT" 41 | ], 42 | "description": "Kirby's custom Composer installer for the Kirby CMS and for Kirby plugins", 43 | "homepage": "https://getkirby.com", 44 | "time": "2020-12-28T12:54:39+00:00" 45 | }, 46 | { 47 | "name": "phpclassic/php-shopify", 48 | "version": "v1.1.16", 49 | "source": { 50 | "type": "git", 51 | "url": "https://github.com/phpclassic/php-shopify.git", 52 | "reference": "1d1c3e83a758ccd603a5b672ec6cd973a0928ac4" 53 | }, 54 | "dist": { 55 | "type": "zip", 56 | "url": "https://api.github.com/repos/phpclassic/php-shopify/zipball/1d1c3e83a758ccd603a5b672ec6cd973a0928ac4", 57 | "reference": "1d1c3e83a758ccd603a5b672ec6cd973a0928ac4", 58 | "shasum": "" 59 | }, 60 | "require": { 61 | "ext-curl": "*", 62 | "ext-json": "*", 63 | "php": ">=5.6" 64 | }, 65 | "require-dev": { 66 | "phpunit/phpunit": "^5.5" 67 | }, 68 | "type": "library", 69 | "autoload": { 70 | "psr-4": { 71 | "PHPShopify\\": "lib/" 72 | } 73 | }, 74 | "notification-url": "https://packagist.org/downloads/", 75 | "license": [ 76 | "Apache-2.0" 77 | ], 78 | "authors": [ 79 | { 80 | "name": "Tareq Mahmood", 81 | "email": "tareqtms@yahoo.com" 82 | } 83 | ], 84 | "description": "PHP SDK for Shopify API", 85 | "homepage": "https://github.com/phpclassic/php-shopify", 86 | "keywords": [ 87 | "php", 88 | "sdk", 89 | "shopify" 90 | ], 91 | "time": "2020-12-17T08:07:12+00:00" 92 | }, 93 | { 94 | "name": "symfony/polyfill-ctype", 95 | "version": "v1.22.0", 96 | "source": { 97 | "type": "git", 98 | "url": "https://github.com/symfony/polyfill-ctype.git", 99 | "reference": "c6c942b1ac76c82448322025e084cadc56048b4e" 100 | }, 101 | "dist": { 102 | "type": "zip", 103 | "url": "https://api.github.com/repos/symfony/polyfill-ctype/zipball/c6c942b1ac76c82448322025e084cadc56048b4e", 104 | "reference": "c6c942b1ac76c82448322025e084cadc56048b4e", 105 | "shasum": "" 106 | }, 107 | "require": { 108 | "php": ">=7.1" 109 | }, 110 | "suggest": { 111 | "ext-ctype": "For best performance" 112 | }, 113 | "type": "library", 114 | "extra": { 115 | "branch-alias": { 116 | "dev-main": "1.22-dev" 117 | }, 118 | "thanks": { 119 | "name": "symfony/polyfill", 120 | "url": "https://github.com/symfony/polyfill" 121 | } 122 | }, 123 | "autoload": { 124 | "psr-4": { 125 | "Symfony\\Polyfill\\Ctype\\": "" 126 | }, 127 | "files": [ 128 | "bootstrap.php" 129 | ] 130 | }, 131 | "notification-url": "https://packagist.org/downloads/", 132 | "license": [ 133 | "MIT" 134 | ], 135 | "authors": [ 136 | { 137 | "name": "Gert de Pagter", 138 | "email": "BackEndTea@gmail.com" 139 | }, 140 | { 141 | "name": "Symfony Community", 142 | "homepage": "https://symfony.com/contributors" 143 | } 144 | ], 145 | "description": "Symfony polyfill for ctype functions", 146 | "homepage": "https://symfony.com", 147 | "keywords": [ 148 | "compatibility", 149 | "ctype", 150 | "polyfill", 151 | "portable" 152 | ], 153 | "time": "2021-01-07T16:49:33+00:00" 154 | }, 155 | { 156 | "name": "vlucas/phpdotenv", 157 | "version": "v2.6.6", 158 | "source": { 159 | "type": "git", 160 | "url": "https://github.com/vlucas/phpdotenv.git", 161 | "reference": "e1d57f62db3db00d9139078cbedf262280701479" 162 | }, 163 | "dist": { 164 | "type": "zip", 165 | "url": "https://api.github.com/repos/vlucas/phpdotenv/zipball/e1d57f62db3db00d9139078cbedf262280701479", 166 | "reference": "e1d57f62db3db00d9139078cbedf262280701479", 167 | "shasum": "" 168 | }, 169 | "require": { 170 | "php": "^5.3.9 || ^7.0 || ^8.0", 171 | "symfony/polyfill-ctype": "^1.17" 172 | }, 173 | "require-dev": { 174 | "ext-filter": "*", 175 | "ext-pcre": "*", 176 | "phpunit/phpunit": "^4.8.35 || ^5.7.27" 177 | }, 178 | "suggest": { 179 | "ext-filter": "Required to use the boolean validator.", 180 | "ext-pcre": "Required to use most of the library." 181 | }, 182 | "type": "library", 183 | "extra": { 184 | "branch-alias": { 185 | "dev-master": "2.6-dev" 186 | } 187 | }, 188 | "autoload": { 189 | "psr-4": { 190 | "Dotenv\\": "src/" 191 | } 192 | }, 193 | "notification-url": "https://packagist.org/downloads/", 194 | "license": [ 195 | "BSD-3-Clause" 196 | ], 197 | "authors": [ 198 | { 199 | "name": "Graham Campbell", 200 | "email": "graham@alt-three.com", 201 | "homepage": "https://gjcampbell.co.uk/" 202 | }, 203 | { 204 | "name": "Vance Lucas", 205 | "email": "vance@vancelucas.com", 206 | "homepage": "https://vancelucas.com/" 207 | } 208 | ], 209 | "description": "Loads environment variables from `.env` to `getenv()`, `$_ENV` and `$_SERVER` automagically.", 210 | "keywords": [ 211 | "dotenv", 212 | "env", 213 | "environment" 214 | ], 215 | "time": "2020-07-14T17:54:18+00:00" 216 | } 217 | ], 218 | "packages-dev": [], 219 | "aliases": [], 220 | "minimum-stability": "stable", 221 | "stability-flags": [], 222 | "prefer-stable": false, 223 | "prefer-lowest": false, 224 | "platform": [], 225 | "platform-dev": [] 226 | } 227 | -------------------------------------------------------------------------------- /example/content/collections/shopify.collections.txt: -------------------------------------------------------------------------------- 1 | title: Collections 2 | -------------------------------------------------------------------------------- /example/content/products/shopify.products.txt: -------------------------------------------------------------------------------- 1 | title: Products 2 | -------------------------------------------------------------------------------- /index.php: -------------------------------------------------------------------------------- 1 | [ 14 | 'cache.api' => true 15 | ], 16 | 'collections' => [ 17 | 'kirby-shopify.productsPage' => function ($site) { 18 | return $site->pages()->filterBy('intendedTemplate', 'shopify.products')->first(); 19 | }, 20 | 'kirby-shopify.products' => function ($site) { 21 | return collection('kirby-shopify.productsPage')->children(); 22 | }, 23 | 'kirby-shopify.collectionsPage' => function ($site) { 24 | return $site->pages()->filterBy('intendedTemplate', 'shopify.collections')->first(); 25 | }, 26 | 'kirby-shopify.collections' => function ($site) { 27 | return collection('kirby-shopify.collectionsPage')->children(); 28 | } 29 | ], 30 | 'pageModels' => [ 31 | 'shopify.products' => 'ShopifyProductsPage', 32 | 'shopify.product' => 'ShopifyProductPage', 33 | 'shopify.collections' => 'ShopifyCollectionsPage', 34 | 'shopify.collection' => 'ShopifyCollectionPage', 35 | ], 36 | 'blueprints' => [ 37 | 'pages/shopify.products' => __DIR__ . '/src/blueprints/shopify.products.yml', 38 | 'pages/shopify.product' => __DIR__ . '/src/blueprints/shopify.product.yml', 39 | 'pages/shopify.collections' => __DIR__ . '/src/blueprints/shopify.collections.yml', 40 | 'pages/shopify.collection' => __DIR__ . '/src/blueprints/shopify.collection.yml' 41 | ], 42 | 'snippets' => [ 43 | 'kirby-shopify.product.structured-data' => __DIR__ . '/src/snippets/product.structured-data.php' 44 | ], 45 | 'fieldMethods' => [ 46 | 'img_url' => function ($field, string $size = '') { 47 | if (is_string($field)) { 48 | $src = $field; 49 | } elseif ($field->src()->isNotEmpty()) { 50 | $src = $field->src(); 51 | } 52 | return preg_replace('/\.(jpg|jpeg|png|bmp|gif)/', '_'.$size.'.$1', $src); 53 | } 54 | ], 55 | 'pageMethods' => [ 56 | 'inventory_quantity' => function () { 57 | $inventory = 0; 58 | foreach ($this->shopifyVariants()->toStructure() as $key => $variant) { 59 | $inventory += $variant->inventory_quantity()->int(); 60 | } 61 | return $inventory; 62 | }, 63 | 'isAvailable' => function () { 64 | return $this->inventory_quantity() > 0; 65 | }, 66 | 'hasImages' => function () { 67 | return $this->shopifyImages()->toStructure()->count() > 0; 68 | }, 69 | 'toProduct' => function () { 70 | return collection('kirby-shopify.products')->findBy('shopifyHandle', $this->shopifyHandle()->value()); 71 | }, 72 | 'toProducts' => function () { 73 | $products = new Collection(); 74 | foreach ($this->children() as $key => $p) { 75 | if ($p = $p->toProduct()) { 76 | $products->add($p); 77 | } 78 | } 79 | return $products; 80 | } 81 | ], 82 | 'routes' => [ 83 | [ 84 | 'pattern' => 'kirby-shopify/api/cache/clear', 85 | 'method' => 'POST', 86 | 'action' => function () { 87 | $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256']; 88 | $data = file_get_contents('php://input'); 89 | $verified = \KirbyShopify\App::verifyWebhook($data, $hmac_header); 90 | 91 | if ($verified) { 92 | \KirbyShopify\App::clearCache(); 93 | \KirbyShopify\App::clearKirbyCache(); 94 | return Response::json(["status" => "success", "code" => 200, "message" => "Cache cleared"]); 95 | } else { 96 | return Response::json(["status" => "success", "code" => 200, "message" => "Identication failed"]); 97 | } 98 | } 99 | ], 100 | [ 101 | 'pattern' => 'kirby-shopify/api/cache/products/clear', 102 | 'method' => 'POST', 103 | 'action' => function () { 104 | $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256']; 105 | $data = file_get_contents('php://input'); 106 | $verified = \KirbyShopify\App::verifyWebhook($data, $hmac_header); 107 | 108 | if ($verified) { 109 | \KirbyShopify\App::clearProductsCache(); 110 | \KirbyShopify\App::clearKirbyCache(); 111 | return Response::json(["status" => "success", "code" => 200, "message" => "Cache cleared"]); 112 | } else { 113 | return Response::json(["status" => "success", "code" => 200, "message" => "Identication failed"]); 114 | } 115 | } 116 | ], 117 | [ 118 | 'pattern' => 'kirby-shopify/api/cache/collections/clear', 119 | 'method' => 'POST', 120 | 'action' => function () { 121 | $hmac_header = $_SERVER['HTTP_X_SHOPIFY_HMAC_SHA256']; 122 | $data = file_get_contents('php://input'); 123 | $verified = \KirbyShopify\App::verifyWebhook($data, $hmac_header); 124 | 125 | if ($verified) { 126 | \KirbyShopify\App::clearCollectionsCache(); 127 | \KirbyShopify\App::clearKirbyCache(); 128 | return Response::json(["status" => "success", "code" => 200, "message" => "Cache cleared"]); 129 | } else { 130 | return Response::json(["status" => "success", "code" => 200, "message" => "Identication failed"]); 131 | } 132 | } 133 | ] 134 | ] 135 | ]); 136 | -------------------------------------------------------------------------------- /src/KirbyShopify.php: -------------------------------------------------------------------------------- 1 | load(); 11 | 12 | class App 13 | { 14 | private static $config = []; 15 | private static $shopify = null; 16 | public static $productsPage = null; 17 | 18 | public static function init() 19 | { 20 | 21 | self::$config = [ 22 | 'ApiKey' => $_ENV['API_KEY'], 23 | 'Password' => $_ENV['API_PASSWORD'], 24 | 'ShopUrl' => $_ENV['SHOP_URL'], 25 | // 'AccessToken' => empty($_ENV['ACCESS_TOKEN']) ? null : $_ENV['ACCESS_TOKEN'], 26 | // 'SharedSecret' => empty($_ENV['SHARED_SECRET']) ? null : $_ENV['SHARED_SECRET'], 27 | ]; 28 | 29 | self::$shopify = new \PHPShopify\ShopifySDK(self::$config); 30 | self::$productsPage = collection('kirby-shopify.productsPage'); 31 | 32 | } 33 | 34 | public static function clearCache() 35 | { 36 | 37 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 38 | $shopifyApiCache->set('products', null); 39 | $shopifyApiCache->set('collections', null); 40 | 41 | } 42 | 43 | public static function clearProductsCache() 44 | { 45 | 46 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 47 | $shopifyApiCache->set('products', null); 48 | 49 | } 50 | 51 | public static function clearCollectionsCache() 52 | { 53 | 54 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 55 | foreach (collection('kirby-shopify.collections') as $key => $c) { 56 | $shopifyApiCache->set('collection-'.$c->shopifyID(), null); 57 | } 58 | $shopifyApiCache->set('collections', null); 59 | 60 | } 61 | 62 | public static function clearKirbyCache() 63 | { 64 | 65 | kirby()->impersonate('kirby'); 66 | kirby()->site()->homepage()->update(); 67 | 68 | } 69 | 70 | public static function getProducts() 71 | { 72 | 73 | if (!self::$shopify) { 74 | \KirbyShopify\App::init(); 75 | } 76 | 77 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 78 | $products = $shopifyApiCache->get('products'); 79 | 80 | if ($products === null) { 81 | $products = []; 82 | $productsCount = self::$shopify->Product->count(['published_status' => 'published', 'status' => 'active']); 83 | 84 | if ($productsCount > 0) { 85 | 86 | $products = self::$shopify->Product->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active']); 87 | 88 | while (count($products) < $productsCount) { 89 | $lastItem = array_values(array_slice($products, -1))[0]; 90 | $nextProducts = self::$shopify->Product->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active', 'since_id' => $lastItem['id']]); 91 | foreach ($nextProducts as $key => $product) { 92 | $products[] = $product; 93 | } 94 | } 95 | 96 | } 97 | $shopifyApiCache->set('products', $products); 98 | } 99 | 100 | return $products; 101 | 102 | } 103 | 104 | public static function getProductsFromCollection($collectionId) 105 | { 106 | 107 | if (!self::$shopify) { 108 | \KirbyShopify\App::init(); 109 | } 110 | 111 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 112 | $products = $shopifyApiCache->get('collection-'.$collectionId); 113 | 114 | if ($products === null) { 115 | $products = []; 116 | $productsCount = self::$shopify->Product->count(['published_status' => 'published', 'status' => 'active', 'collection_id' => $collectionId]); 117 | 118 | if ($productsCount > 0) { 119 | 120 | $products = self::$shopify->Product->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active', 'collection_id' => $collectionId]); 121 | 122 | while (count($products) < $productsCount) { 123 | $lastItem = array_values(array_slice($products, -1))[0]; 124 | $nextProducts = self::$shopify->Product->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active', 'since_id' => $lastItem['id'], 'collection_id' => $collectionId]); 125 | foreach ($nextProducts as $key => $product) { 126 | $products[] = $product; 127 | } 128 | } 129 | 130 | } 131 | $shopifyApiCache->set('collection-'.$collectionId, $products); 132 | } 133 | 134 | return $products; 135 | 136 | } 137 | 138 | public static function getProduct($id) 139 | { 140 | 141 | if (!self::$shopify) { 142 | \KirbyShopify\App::init(); 143 | } 144 | 145 | return $id ? self::$shopify->Product($id)->get() : null; 146 | 147 | } 148 | 149 | public static function getCollections() 150 | { 151 | 152 | if (!self::$shopify) { 153 | \KirbyShopify\App::init(); 154 | } 155 | 156 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 157 | $collections = $shopifyApiCache->get('collections'); 158 | 159 | if ($collections === null) { 160 | $smartCollections = self::getSmartCollections(); 161 | $customCollections = self::getCustomCollections(); 162 | $collections = array_merge($smartCollections, $customCollections); 163 | $shopifyApiCache->set('collections', $collections); 164 | } 165 | 166 | return $collections; 167 | 168 | } 169 | 170 | public static function getCustomCollections() 171 | { 172 | 173 | if (!self::$shopify) { 174 | \KirbyShopify\App::init(); 175 | } 176 | 177 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 178 | $collections = $shopifyApiCache->get('collections'); 179 | 180 | if ($collections === null) { 181 | $collections = []; 182 | $collectionsCount = self::$shopify->CustomCollection->count(['published_status' => 'published', 'status' => 'active']); 183 | 184 | if ($collectionsCount > 0) { 185 | 186 | $collections = self::$shopify->CustomCollection->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active']); 187 | 188 | while (count($collections) < $collectionsCount) { 189 | $lastItem = array_values(array_slice($collections, -1))[0]; 190 | $nextCollections = self::$shopify->CustomCollection->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active', 'since_id' => $lastItem['id']]); 191 | foreach ($nextCollections as $key => $collection) { 192 | $collections[] = $collection; 193 | } 194 | } 195 | 196 | } 197 | $shopifyApiCache->set('collections', $collections); 198 | } 199 | 200 | return $collections; 201 | 202 | } 203 | 204 | public static function getSmartCollections() 205 | { 206 | 207 | if (!self::$shopify) { 208 | \KirbyShopify\App::init(); 209 | } 210 | 211 | $shopifyApiCache = kirby()->cache('tristanb.kirby-shopify.api'); 212 | $collections = $shopifyApiCache->get('collections'); 213 | 214 | if ($collections === null) { 215 | $collections = []; 216 | $collectionsCount = self::$shopify->SmartCollection->count(['published_status' => 'published', 'status' => 'active']); 217 | 218 | if ($collectionsCount > 0) { 219 | 220 | $collections = self::$shopify->SmartCollection->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active']); 221 | 222 | while (count($collections) < $collectionsCount) { 223 | $lastItem = array_values(array_slice($collections, -1))[0]; 224 | $nextCollections = self::$shopify->SmartCollection->get(['limit' => 250, 'published_status' => 'published', 'status' => 'active', 'since_id' => $lastItem['id']]); 225 | foreach ($nextCollections as $key => $collection) { 226 | $collections[] = $collection; 227 | } 228 | } 229 | 230 | } 231 | $shopifyApiCache->set('collections', $collections); 232 | } 233 | 234 | return $collections; 235 | 236 | } 237 | 238 | public static function verifyWebhook($data, $hmac_header) 239 | { 240 | 241 | if ($_ENV['SHOPIFY_APP_SECRET']) { 242 | $calculated_hmac = base64_encode(hash_hmac('sha256', $data, $_ENV['SHOPIFY_APP_SECRET'], true)); 243 | return hash_equals($hmac_header, $calculated_hmac); 244 | } 245 | 246 | } 247 | 248 | } 249 | -------------------------------------------------------------------------------- /src/blueprints/shopify.collection.yml: -------------------------------------------------------------------------------- 1 | title: Collection 2 | options: 3 | delete: false 4 | changeTitle: false 5 | changeTemplate: false 6 | changeSlug: false 7 | changeStatus: false 8 | sections: 9 | shopify: 10 | type: fields 11 | fields: 12 | shopifyTitle: 13 | label: Title 14 | type: text 15 | disabled: true 16 | width: 2/4 17 | shopifyID: 18 | label: ID 19 | type: text 20 | disabled: true 21 | width: 1/4 22 | shopifyHandle: 23 | label: Handle 24 | type: text 25 | disabled: true 26 | width: 1/4 27 | shopifyFeaturedImage: 28 | label: Featured 29 | type: structure 30 | fields: 31 | src: 32 | label: URL 33 | type: url 34 | disabled: true 35 | width: 1/2 36 | shopifyDescriptionHTML: 37 | label: Description 38 | type: textarea 39 | disabled: true 40 | products: 41 | headline: Products 42 | type: pages 43 | info: "{{ page.handle }}" 44 | template: shopify.product 45 | -------------------------------------------------------------------------------- /src/blueprints/shopify.collections.yml: -------------------------------------------------------------------------------- 1 | title: Collections 2 | options: 3 | delete: false 4 | changeTemplate: false 5 | changeStatus: true 6 | sections: 7 | collections: 8 | headline: Collections 9 | type: pages 10 | info: "{{ page.handle }}" 11 | template: shopify.collection 12 | -------------------------------------------------------------------------------- /src/blueprints/shopify.product.yml: -------------------------------------------------------------------------------- 1 | title: Product 2 | options: 3 | delete: false 4 | changeTitle: false 5 | changeTemplate: false 6 | changeSlug: false 7 | changeStatus: false 8 | sections: 9 | shopify: 10 | type: fields 11 | fields: 12 | shopifyTitle: 13 | label: Title 14 | type: text 15 | disabled: true 16 | width: 2/4 17 | shopifyID: 18 | label: ID 19 | type: text 20 | disabled: true 21 | width: 1/4 22 | shopifyHandle: 23 | label: Handle 24 | type: text 25 | disabled: true 26 | width: 1/4 27 | shopifyPrice: 28 | label: Price 29 | type: text 30 | disabled: true 31 | width: 1/4 32 | shopifyCompareAtPrice: 33 | label: Compare At Price 34 | type: text 35 | disabled: true 36 | width: 1/4 37 | shopifyFeaturedImage: 38 | label: Featured 39 | type: structure 40 | fields: 41 | src: 42 | label: URL 43 | type: url 44 | disabled: true 45 | width: 1/2 46 | shopifyDescriptionHTML: 47 | label: Description 48 | type: textarea 49 | disabled: true 50 | shopifyImages: 51 | label: Images 52 | type: structure 53 | fields: 54 | src: 55 | label: URL 56 | type: url 57 | disabled: true 58 | shopifyVariants: 59 | label: Variants 60 | type: structure 61 | fields: 62 | title: 63 | label: Title 64 | type: text 65 | price: 66 | label: Price 67 | type: text 68 | compare_at_price: 69 | label: Compare at price 70 | type: text 71 | inventory_quantity: 72 | label: Inventory 73 | type: text 74 | sku: 75 | label: SKU 76 | type: text 77 | disabled: true 78 | shopifyURL: 79 | label: URL 80 | type: url 81 | disabled: true 82 | shopifyType: 83 | label: Type 84 | type: text 85 | disabled: true 86 | width: 1/2 87 | shopifyVendor: 88 | label: Vendor 89 | type: text 90 | disabled: true 91 | width: 1/2 92 | shopifyTags: 93 | label: Tags 94 | type: tags 95 | separator: , 96 | disabled: true 97 | -------------------------------------------------------------------------------- /src/blueprints/shopify.products.yml: -------------------------------------------------------------------------------- 1 | title: Products 2 | options: 3 | delete: false 4 | changeTemplate: false 5 | changeStatus: true 6 | sections: 7 | products: 8 | headline: Products 9 | type: pages 10 | info: "{{ page.handle }}" 11 | template: shopify.product 12 | -------------------------------------------------------------------------------- /src/helpers.php: -------------------------------------------------------------------------------- 1 | shopifyID()->value(), $this->shopifyHandle()->value()); 8 | $productsPage = \KirbyShopify\App::$productsPage; 9 | $pages = []; 10 | 11 | foreach ($products as $key => $product) { 12 | $kirbyProduct = null; 13 | // $kirbyProductRoot = $productsPage->root() . '/' . Str::slug($product['handle']) . '/shopify.product.txt'; 14 | // $kirbyProduct = F::exists($kirbyProductRoot) ? new \Kirby\Toolkit\Collection(\Kirby\Data\Data::read($kirbyProductRoot)) : false; 15 | // if($kirbyProduct) $kirbyProduct = $kirbyProduct->toArray(); 16 | 17 | $shopifyProduct = [ 18 | 'title' => $product['title'], 19 | // 'shopifyTitle' => $product['title'], 20 | 'shopifyID' => $product['id'], 21 | 'shopifyHandle' => $product['handle'], 22 | // 'shopifyFeaturedImage' => count($product['images']) > 0 ? $product['images'][0]['src'] : '', 23 | // 'shopifyImages' => \Kirby\Data\Yaml::encode($product['images']), 24 | // 'shopifyDescriptionHTML' => $product['body_html'], 25 | // 'shopifyPrice' => count($product['variants']) > 0 ? $product['variants'][0]['price'] : '', 26 | // 'shopifyCompareAtPrice' => count($product['variants']) > 0 ? $product['variants'][0]['compare_at_price'] : '', 27 | // 'shopifyType' => $product['product_type'], 28 | // 'shopifyTags' => $product['tags'], 29 | // 'shopifyVariants' => \Kirby\Data\Yaml::encode($product['variants']), 30 | ]; 31 | 32 | if ($kirbyProduct) { 33 | foreach ($shopifyProduct as $k => $value) { 34 | unset($kirbyProduct[strtolower($k)]); 35 | } 36 | } 37 | 38 | $pages[] = [ 39 | 'slug' => Str::slug($product['handle']), 40 | 'num' => $key+1, 41 | 'template' => 'shopify.product', 42 | 'model' => 'shopify.product', 43 | 'content' => 44 | $kirbyProduct 45 | ? 46 | ($shopifyProduct + $kirbyProduct) 47 | : 48 | $shopifyProduct, 49 | ]; 50 | } 51 | 52 | return Pages::factory($pages, $this); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /src/models/shopify.collections.php: -------------------------------------------------------------------------------- 1 | $collection) { 14 | 15 | $slug = Str::slug($collection['handle']); 16 | $kirbyCollectionRoot = page('collections')->root() . '/' . $collection['id'] . '_' . $slug . '/shopify.collection.txt'; 17 | $kirbyCollection = F::exists($kirbyCollectionRoot) ? new \Kirby\Toolkit\Collection(\Kirby\Data\Data::read($kirbyCollectionRoot)) : false; 18 | 19 | $shopifyCollection = [ 20 | 'title' => $collection['title'], 21 | 'shopifyTitle' => $collection['title'], 22 | 'shopifyID' => $collection['id'], 23 | 'shopifyHandle' => $collection['handle'], 24 | 'shopifyFeaturedImage' => !empty($collection['image']) ? \Kirby\Data\Yaml::encode($collection['image']) : '', 25 | 'shopifyDescriptionHTML' => $collection['body_html'] 26 | ]; 27 | 28 | $pages[] = [ 29 | 'slug' => $slug, 30 | 'num' => $collection['id'], 31 | 'template' => 'shopify.collection', 32 | 'model' => 'shopify.collection', 33 | 'content' => 34 | $kirbyCollection 35 | ? 36 | array_merge($kirbyCollection->toArray(), $shopifyCollection) 37 | : 38 | $shopifyCollection, 39 | ]; 40 | } 41 | 42 | return Pages::factory($pages, $this); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /src/models/shopify.product.php: -------------------------------------------------------------------------------- 1 | inventory()['children'], $this); 11 | } 12 | 13 | public function children(): Pages 14 | { 15 | 16 | $products = \KirbyShopify\App::getProducts(); 17 | $productsPage = \KirbyShopify\App::$productsPage; 18 | $pages = []; 19 | 20 | foreach ($products as $key => $product) { 21 | $slug = Str::slug($product['handle']); 22 | $kirbyProductRoot = $productsPage->root() . '/' . $product['id'] . '_' . $slug . '/shopify.product.txt'; 23 | $kirbyProduct = F::exists($kirbyProductRoot) ? new \Kirby\Toolkit\Collection(\Kirby\Data\Data::read($kirbyProductRoot)) : false; 24 | if($kirbyProduct) $kirbyProduct = $kirbyProduct->toArray(); 25 | // $kirbyProduct = $this->subpages()->find($slug); 26 | // $kirbyProduct = $kirbyProduct ? $kirbyProduct->toArray() : null; 27 | 28 | $shopifyProduct = [ 29 | 'title' => $product['title'], 30 | 'shopifyTitle' => $product['title'], 31 | 'shopifyID' => $product['id'], 32 | 'shopifyCreatedAt' => $product['created_at'], 33 | 'shopifyUpdatedAt' => $product['updated_at'], 34 | 'shopifyPublishedAt' => $product['published_at'], 35 | 'shopifyHandle' => $product['handle'], 36 | 'shopifyVendor' => $product['vendor'], 37 | 'shopifyFeaturedImage' => count($product['images']) > 0 ? \Kirby\Data\Yaml::encode([$product['images'][0]]) : '', 38 | 'shopifyImages' => \Kirby\Data\Yaml::encode($product['images']), 39 | 'shopifyDescriptionHTML' => $product['body_html'], 40 | 'shopifyPrice' => count($product['variants']) > 0 ? $product['variants'][0]['price'] : '', 41 | 'shopifyCompareAtPrice' => count($product['variants']) > 0 ? $product['variants'][0]['compare_at_price'] : '', 42 | 'shopifyType' => $product['product_type'], 43 | 'shopifyTags' => $product['tags'], 44 | 'shopifyVariants' => \Kirby\Data\Yaml::encode($product['variants']), 45 | ]; 46 | 47 | if ($kirbyProduct) { 48 | foreach ($shopifyProduct as $k => $value) { 49 | unset($kirbyProduct[strtolower($k)]); 50 | } 51 | } 52 | 53 | $pages[] = [ 54 | 'slug' => $slug, 55 | 'num' => $product['id'], 56 | 'template' => 'shopify.product', 57 | 'model' => 'shopify.product', 58 | 'content' => 59 | $kirbyProduct 60 | ? 61 | ($shopifyProduct + $kirbyProduct) 62 | : 63 | $shopifyProduct, 64 | ]; 65 | } 66 | 67 | return Pages::factory($pages, $this); 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /src/snippets/product.structured-data.php: -------------------------------------------------------------------------------- 1 | shopifyImages()->toStructure() ?> 2 | 3 | 53 | -------------------------------------------------------------------------------- /vendor/autoload.php: -------------------------------------------------------------------------------- 1 | 7 | * Jordi Boggiano 8 | * 9 | * For the full copyright and license information, please view the LICENSE 10 | * file that was distributed with this source code. 11 | */ 12 | 13 | namespace Composer\Autoload; 14 | 15 | /** 16 | * ClassLoader implements a PSR-0, PSR-4 and classmap class loader. 17 | * 18 | * $loader = new \Composer\Autoload\ClassLoader(); 19 | * 20 | * // register classes with namespaces 21 | * $loader->add('Symfony\Component', __DIR__.'/component'); 22 | * $loader->add('Symfony', __DIR__.'/framework'); 23 | * 24 | * // activate the autoloader 25 | * $loader->register(); 26 | * 27 | * // to enable searching the include path (eg. for PEAR packages) 28 | * $loader->setUseIncludePath(true); 29 | * 30 | * In this example, if you try to use a class in the Symfony\Component 31 | * namespace or one of its children (Symfony\Component\Console for instance), 32 | * the autoloader will first look for the class under the component/ 33 | * directory, and it will then fallback to the framework/ directory if not 34 | * found before giving up. 35 | * 36 | * This class is loosely based on the Symfony UniversalClassLoader. 37 | * 38 | * @author Fabien Potencier 39 | * @author Jordi Boggiano 40 | * @see http://www.php-fig.org/psr/psr-0/ 41 | * @see http://www.php-fig.org/psr/psr-4/ 42 | */ 43 | class ClassLoader 44 | { 45 | // PSR-4 46 | private $prefixLengthsPsr4 = array(); 47 | private $prefixDirsPsr4 = array(); 48 | private $fallbackDirsPsr4 = array(); 49 | 50 | // PSR-0 51 | private $prefixesPsr0 = array(); 52 | private $fallbackDirsPsr0 = array(); 53 | 54 | private $useIncludePath = false; 55 | private $classMap = array(); 56 | private $classMapAuthoritative = false; 57 | private $missingClasses = array(); 58 | private $apcuPrefix; 59 | 60 | public function getPrefixes() 61 | { 62 | if (!empty($this->prefixesPsr0)) { 63 | return call_user_func_array('array_merge', $this->prefixesPsr0); 64 | } 65 | 66 | return array(); 67 | } 68 | 69 | public function getPrefixesPsr4() 70 | { 71 | return $this->prefixDirsPsr4; 72 | } 73 | 74 | public function getFallbackDirs() 75 | { 76 | return $this->fallbackDirsPsr0; 77 | } 78 | 79 | public function getFallbackDirsPsr4() 80 | { 81 | return $this->fallbackDirsPsr4; 82 | } 83 | 84 | public function getClassMap() 85 | { 86 | return $this->classMap; 87 | } 88 | 89 | /** 90 | * @param array $classMap Class to filename map 91 | */ 92 | public function addClassMap(array $classMap) 93 | { 94 | if ($this->classMap) { 95 | $this->classMap = array_merge($this->classMap, $classMap); 96 | } else { 97 | $this->classMap = $classMap; 98 | } 99 | } 100 | 101 | /** 102 | * Registers a set of PSR-0 directories for a given prefix, either 103 | * appending or prepending to the ones previously set for this prefix. 104 | * 105 | * @param string $prefix The prefix 106 | * @param array|string $paths The PSR-0 root directories 107 | * @param bool $prepend Whether to prepend the directories 108 | */ 109 | public function add($prefix, $paths, $prepend = false) 110 | { 111 | if (!$prefix) { 112 | if ($prepend) { 113 | $this->fallbackDirsPsr0 = array_merge( 114 | (array) $paths, 115 | $this->fallbackDirsPsr0 116 | ); 117 | } else { 118 | $this->fallbackDirsPsr0 = array_merge( 119 | $this->fallbackDirsPsr0, 120 | (array) $paths 121 | ); 122 | } 123 | 124 | return; 125 | } 126 | 127 | $first = $prefix[0]; 128 | if (!isset($this->prefixesPsr0[$first][$prefix])) { 129 | $this->prefixesPsr0[$first][$prefix] = (array) $paths; 130 | 131 | return; 132 | } 133 | if ($prepend) { 134 | $this->prefixesPsr0[$first][$prefix] = array_merge( 135 | (array) $paths, 136 | $this->prefixesPsr0[$first][$prefix] 137 | ); 138 | } else { 139 | $this->prefixesPsr0[$first][$prefix] = array_merge( 140 | $this->prefixesPsr0[$first][$prefix], 141 | (array) $paths 142 | ); 143 | } 144 | } 145 | 146 | /** 147 | * Registers a set of PSR-4 directories for a given namespace, either 148 | * appending or prepending to the ones previously set for this namespace. 149 | * 150 | * @param string $prefix The prefix/namespace, with trailing '\\' 151 | * @param array|string $paths The PSR-4 base directories 152 | * @param bool $prepend Whether to prepend the directories 153 | * 154 | * @throws \InvalidArgumentException 155 | */ 156 | public function addPsr4($prefix, $paths, $prepend = false) 157 | { 158 | if (!$prefix) { 159 | // Register directories for the root namespace. 160 | if ($prepend) { 161 | $this->fallbackDirsPsr4 = array_merge( 162 | (array) $paths, 163 | $this->fallbackDirsPsr4 164 | ); 165 | } else { 166 | $this->fallbackDirsPsr4 = array_merge( 167 | $this->fallbackDirsPsr4, 168 | (array) $paths 169 | ); 170 | } 171 | } elseif (!isset($this->prefixDirsPsr4[$prefix])) { 172 | // Register directories for a new namespace. 173 | $length = strlen($prefix); 174 | if ('\\' !== $prefix[$length - 1]) { 175 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 176 | } 177 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 178 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 179 | } elseif ($prepend) { 180 | // Prepend directories for an already registered namespace. 181 | $this->prefixDirsPsr4[$prefix] = array_merge( 182 | (array) $paths, 183 | $this->prefixDirsPsr4[$prefix] 184 | ); 185 | } else { 186 | // Append directories for an already registered namespace. 187 | $this->prefixDirsPsr4[$prefix] = array_merge( 188 | $this->prefixDirsPsr4[$prefix], 189 | (array) $paths 190 | ); 191 | } 192 | } 193 | 194 | /** 195 | * Registers a set of PSR-0 directories for a given prefix, 196 | * replacing any others previously set for this prefix. 197 | * 198 | * @param string $prefix The prefix 199 | * @param array|string $paths The PSR-0 base directories 200 | */ 201 | public function set($prefix, $paths) 202 | { 203 | if (!$prefix) { 204 | $this->fallbackDirsPsr0 = (array) $paths; 205 | } else { 206 | $this->prefixesPsr0[$prefix[0]][$prefix] = (array) $paths; 207 | } 208 | } 209 | 210 | /** 211 | * Registers a set of PSR-4 directories for a given namespace, 212 | * replacing any others previously set for this namespace. 213 | * 214 | * @param string $prefix The prefix/namespace, with trailing '\\' 215 | * @param array|string $paths The PSR-4 base directories 216 | * 217 | * @throws \InvalidArgumentException 218 | */ 219 | public function setPsr4($prefix, $paths) 220 | { 221 | if (!$prefix) { 222 | $this->fallbackDirsPsr4 = (array) $paths; 223 | } else { 224 | $length = strlen($prefix); 225 | if ('\\' !== $prefix[$length - 1]) { 226 | throw new \InvalidArgumentException("A non-empty PSR-4 prefix must end with a namespace separator."); 227 | } 228 | $this->prefixLengthsPsr4[$prefix[0]][$prefix] = $length; 229 | $this->prefixDirsPsr4[$prefix] = (array) $paths; 230 | } 231 | } 232 | 233 | /** 234 | * Turns on searching the include path for class files. 235 | * 236 | * @param bool $useIncludePath 237 | */ 238 | public function setUseIncludePath($useIncludePath) 239 | { 240 | $this->useIncludePath = $useIncludePath; 241 | } 242 | 243 | /** 244 | * Can be used to check if the autoloader uses the include path to check 245 | * for classes. 246 | * 247 | * @return bool 248 | */ 249 | public function getUseIncludePath() 250 | { 251 | return $this->useIncludePath; 252 | } 253 | 254 | /** 255 | * Turns off searching the prefix and fallback directories for classes 256 | * that have not been registered with the class map. 257 | * 258 | * @param bool $classMapAuthoritative 259 | */ 260 | public function setClassMapAuthoritative($classMapAuthoritative) 261 | { 262 | $this->classMapAuthoritative = $classMapAuthoritative; 263 | } 264 | 265 | /** 266 | * Should class lookup fail if not found in the current class map? 267 | * 268 | * @return bool 269 | */ 270 | public function isClassMapAuthoritative() 271 | { 272 | return $this->classMapAuthoritative; 273 | } 274 | 275 | /** 276 | * APCu prefix to use to cache found/not-found classes, if the extension is enabled. 277 | * 278 | * @param string|null $apcuPrefix 279 | */ 280 | public function setApcuPrefix($apcuPrefix) 281 | { 282 | $this->apcuPrefix = function_exists('apcu_fetch') && ini_get('apc.enabled') ? $apcuPrefix : null; 283 | } 284 | 285 | /** 286 | * The APCu prefix in use, or null if APCu caching is not enabled. 287 | * 288 | * @return string|null 289 | */ 290 | public function getApcuPrefix() 291 | { 292 | return $this->apcuPrefix; 293 | } 294 | 295 | /** 296 | * Registers this instance as an autoloader. 297 | * 298 | * @param bool $prepend Whether to prepend the autoloader or not 299 | */ 300 | public function register($prepend = false) 301 | { 302 | spl_autoload_register(array($this, 'loadClass'), true, $prepend); 303 | } 304 | 305 | /** 306 | * Unregisters this instance as an autoloader. 307 | */ 308 | public function unregister() 309 | { 310 | spl_autoload_unregister(array($this, 'loadClass')); 311 | } 312 | 313 | /** 314 | * Loads the given class or interface. 315 | * 316 | * @param string $class The name of the class 317 | * @return bool|null True if loaded, null otherwise 318 | */ 319 | public function loadClass($class) 320 | { 321 | if ($file = $this->findFile($class)) { 322 | includeFile($file); 323 | 324 | return true; 325 | } 326 | } 327 | 328 | /** 329 | * Finds the path to the file where the class is defined. 330 | * 331 | * @param string $class The name of the class 332 | * 333 | * @return string|false The path if found, false otherwise 334 | */ 335 | public function findFile($class) 336 | { 337 | // class map lookup 338 | if (isset($this->classMap[$class])) { 339 | return $this->classMap[$class]; 340 | } 341 | if ($this->classMapAuthoritative || isset($this->missingClasses[$class])) { 342 | return false; 343 | } 344 | if (null !== $this->apcuPrefix) { 345 | $file = apcu_fetch($this->apcuPrefix.$class, $hit); 346 | if ($hit) { 347 | return $file; 348 | } 349 | } 350 | 351 | $file = $this->findFileWithExtension($class, '.php'); 352 | 353 | // Search for Hack files if we are running on HHVM 354 | if (false === $file && defined('HHVM_VERSION')) { 355 | $file = $this->findFileWithExtension($class, '.hh'); 356 | } 357 | 358 | if (null !== $this->apcuPrefix) { 359 | apcu_add($this->apcuPrefix.$class, $file); 360 | } 361 | 362 | if (false === $file) { 363 | // Remember that this class does not exist. 364 | $this->missingClasses[$class] = true; 365 | } 366 | 367 | return $file; 368 | } 369 | 370 | private function findFileWithExtension($class, $ext) 371 | { 372 | // PSR-4 lookup 373 | $logicalPathPsr4 = strtr($class, '\\', DIRECTORY_SEPARATOR) . $ext; 374 | 375 | $first = $class[0]; 376 | if (isset($this->prefixLengthsPsr4[$first])) { 377 | $subPath = $class; 378 | while (false !== $lastPos = strrpos($subPath, '\\')) { 379 | $subPath = substr($subPath, 0, $lastPos); 380 | $search = $subPath.'\\'; 381 | if (isset($this->prefixDirsPsr4[$search])) { 382 | $pathEnd = DIRECTORY_SEPARATOR . substr($logicalPathPsr4, $lastPos + 1); 383 | foreach ($this->prefixDirsPsr4[$search] as $dir) { 384 | if (file_exists($file = $dir . $pathEnd)) { 385 | return $file; 386 | } 387 | } 388 | } 389 | } 390 | } 391 | 392 | // PSR-4 fallback dirs 393 | foreach ($this->fallbackDirsPsr4 as $dir) { 394 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr4)) { 395 | return $file; 396 | } 397 | } 398 | 399 | // PSR-0 lookup 400 | if (false !== $pos = strrpos($class, '\\')) { 401 | // namespaced class name 402 | $logicalPathPsr0 = substr($logicalPathPsr4, 0, $pos + 1) 403 | . strtr(substr($logicalPathPsr4, $pos + 1), '_', DIRECTORY_SEPARATOR); 404 | } else { 405 | // PEAR-like class name 406 | $logicalPathPsr0 = strtr($class, '_', DIRECTORY_SEPARATOR) . $ext; 407 | } 408 | 409 | if (isset($this->prefixesPsr0[$first])) { 410 | foreach ($this->prefixesPsr0[$first] as $prefix => $dirs) { 411 | if (0 === strpos($class, $prefix)) { 412 | foreach ($dirs as $dir) { 413 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 414 | return $file; 415 | } 416 | } 417 | } 418 | } 419 | } 420 | 421 | // PSR-0 fallback dirs 422 | foreach ($this->fallbackDirsPsr0 as $dir) { 423 | if (file_exists($file = $dir . DIRECTORY_SEPARATOR . $logicalPathPsr0)) { 424 | return $file; 425 | } 426 | } 427 | 428 | // PSR-0 include paths. 429 | if ($this->useIncludePath && $file = stream_resolve_include_path($logicalPathPsr0)) { 430 | return $file; 431 | } 432 | 433 | return false; 434 | } 435 | } 436 | 437 | /** 438 | * Scope isolated include. 439 | * 440 | * Prevents access to $this/self from included files. 441 | */ 442 | function includeFile($file) 443 | { 444 | include $file; 445 | } 446 | -------------------------------------------------------------------------------- /vendor/composer/autoload_classmap.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/vlucas/phpdotenv/src/Dotenv.php', 10 | 'Dotenv\\Exception\\ExceptionInterface' => $vendorDir . '/vlucas/phpdotenv/src/Exception/ExceptionInterface.php', 11 | 'Dotenv\\Exception\\InvalidCallbackException' => $vendorDir . '/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php', 12 | 'Dotenv\\Exception\\InvalidFileException' => $vendorDir . '/vlucas/phpdotenv/src/Exception/InvalidFileException.php', 13 | 'Dotenv\\Exception\\InvalidPathException' => $vendorDir . '/vlucas/phpdotenv/src/Exception/InvalidPathException.php', 14 | 'Dotenv\\Exception\\ValidationException' => $vendorDir . '/vlucas/phpdotenv/src/Exception/ValidationException.php', 15 | 'Dotenv\\Loader' => $vendorDir . '/vlucas/phpdotenv/src/Loader.php', 16 | 'Dotenv\\Parser' => $vendorDir . '/vlucas/phpdotenv/src/Parser.php', 17 | 'Dotenv\\Validator' => $vendorDir . '/vlucas/phpdotenv/src/Validator.php', 18 | 'Kirby\\ComposerInstaller\\CmsInstaller' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/CmsInstaller.php', 19 | 'Kirby\\ComposerInstaller\\Installer' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/Installer.php', 20 | 'Kirby\\ComposerInstaller\\Plugin' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/Plugin.php', 21 | 'Kirby\\ComposerInstaller\\PluginInstaller' => $vendorDir . '/getkirby/composer-installer/src/ComposerInstaller/PluginInstaller.php', 22 | 'PHPShopify\\AbandonedCheckout' => $vendorDir . '/phpclassic/php-shopify/lib/AbandonedCheckout.php', 23 | 'PHPShopify\\ApplicationCharge' => $vendorDir . '/phpclassic/php-shopify/lib/ApplicationCharge.php', 24 | 'PHPShopify\\Article' => $vendorDir . '/phpclassic/php-shopify/lib/Article.php', 25 | 'PHPShopify\\Asset' => $vendorDir . '/phpclassic/php-shopify/lib/Asset.php', 26 | 'PHPShopify\\AuthHelper' => $vendorDir . '/phpclassic/php-shopify/lib/AuthHelper.php', 27 | 'PHPShopify\\Balance' => $vendorDir . '/phpclassic/php-shopify/lib/Balance.php', 28 | 'PHPShopify\\Batch' => $vendorDir . '/phpclassic/php-shopify/lib/Batch.php', 29 | 'PHPShopify\\Blog' => $vendorDir . '/phpclassic/php-shopify/lib/Blog.php', 30 | 'PHPShopify\\CarrierService' => $vendorDir . '/phpclassic/php-shopify/lib/CarrierService.php', 31 | 'PHPShopify\\Collect' => $vendorDir . '/phpclassic/php-shopify/lib/Collect.php', 32 | 'PHPShopify\\Collection' => $vendorDir . '/phpclassic/php-shopify/lib/Collection.php', 33 | 'PHPShopify\\Comment' => $vendorDir . '/phpclassic/php-shopify/lib/Comment.php', 34 | 'PHPShopify\\Country' => $vendorDir . '/phpclassic/php-shopify/lib/Country.php', 35 | 'PHPShopify\\CurlRequest' => $vendorDir . '/phpclassic/php-shopify/lib/CurlRequest.php', 36 | 'PHPShopify\\CurlResponse' => $vendorDir . '/phpclassic/php-shopify/lib/CurlResponse.php', 37 | 'PHPShopify\\Currency' => $vendorDir . '/phpclassic/php-shopify/lib/Currency.php', 38 | 'PHPShopify\\CustomCollection' => $vendorDir . '/phpclassic/php-shopify/lib/CustomCollection.php', 39 | 'PHPShopify\\Customer' => $vendorDir . '/phpclassic/php-shopify/lib/Customer.php', 40 | 'PHPShopify\\CustomerAddress' => $vendorDir . '/phpclassic/php-shopify/lib/CustomerAddress.php', 41 | 'PHPShopify\\CustomerSavedSearch' => $vendorDir . '/phpclassic/php-shopify/lib/CustomerSavedSearch.php', 42 | 'PHPShopify\\Discount' => $vendorDir . '/phpclassic/php-shopify/lib/Discount.php', 43 | 'PHPShopify\\DiscountCode' => $vendorDir . '/phpclassic/php-shopify/lib/DiscountCode.php', 44 | 'PHPShopify\\Dispute' => $vendorDir . '/phpclassic/php-shopify/lib/Dispute.php', 45 | 'PHPShopify\\DraftOrder' => $vendorDir . '/phpclassic/php-shopify/lib/DraftOrder.php', 46 | 'PHPShopify\\Event' => $vendorDir . '/phpclassic/php-shopify/lib/Event.php', 47 | 'PHPShopify\\Exception\\ApiException' => $vendorDir . '/phpclassic/php-shopify/lib/Exception/ApiException.php', 48 | 'PHPShopify\\Exception\\CurlException' => $vendorDir . '/phpclassic/php-shopify/lib/Exception/CurlException.php', 49 | 'PHPShopify\\Exception\\ResourceRateLimitException' => $vendorDir . '/phpclassic/php-shopify/lib/Exception/ResourceRateLimitException.php', 50 | 'PHPShopify\\Exception\\SdkException' => $vendorDir . '/phpclassic/php-shopify/lib/Exception/SdkException.php', 51 | 'PHPShopify\\Fulfillment' => $vendorDir . '/phpclassic/php-shopify/lib/Fulfillment.php', 52 | 'PHPShopify\\FulfillmentEvent' => $vendorDir . '/phpclassic/php-shopify/lib/FulfillmentEvent.php', 53 | 'PHPShopify\\FulfillmentService' => $vendorDir . '/phpclassic/php-shopify/lib/FulfillmentService.php', 54 | 'PHPShopify\\GiftCard' => $vendorDir . '/phpclassic/php-shopify/lib/GiftCard.php', 55 | 'PHPShopify\\GraphQL' => $vendorDir . '/phpclassic/php-shopify/lib/GraphQL.php', 56 | 'PHPShopify\\HttpRequestGraphQL' => $vendorDir . '/phpclassic/php-shopify/lib/HttpRequestGraphQL.php', 57 | 'PHPShopify\\HttpRequestJson' => $vendorDir . '/phpclassic/php-shopify/lib/HttpRequestJson.php', 58 | 'PHPShopify\\InventoryItem' => $vendorDir . '/phpclassic/php-shopify/lib/InventoryItem.php', 59 | 'PHPShopify\\InventoryLevel' => $vendorDir . '/phpclassic/php-shopify/lib/InventoryLevel.php', 60 | 'PHPShopify\\Location' => $vendorDir . '/phpclassic/php-shopify/lib/Location.php', 61 | 'PHPShopify\\Metafield' => $vendorDir . '/phpclassic/php-shopify/lib/Metafield.php', 62 | 'PHPShopify\\Multipass' => $vendorDir . '/phpclassic/php-shopify/lib/Multipass.php', 63 | 'PHPShopify\\Order' => $vendorDir . '/phpclassic/php-shopify/lib/Order.php', 64 | 'PHPShopify\\OrderRisk' => $vendorDir . '/phpclassic/php-shopify/lib/OrderRisk.php', 65 | 'PHPShopify\\Page' => $vendorDir . '/phpclassic/php-shopify/lib/Page.php', 66 | 'PHPShopify\\Payouts' => $vendorDir . '/phpclassic/php-shopify/lib/Payouts.php', 67 | 'PHPShopify\\Policy' => $vendorDir . '/phpclassic/php-shopify/lib/Policy.php', 68 | 'PHPShopify\\PriceRule' => $vendorDir . '/phpclassic/php-shopify/lib/PriceRule.php', 69 | 'PHPShopify\\Product' => $vendorDir . '/phpclassic/php-shopify/lib/Product.php', 70 | 'PHPShopify\\ProductImage' => $vendorDir . '/phpclassic/php-shopify/lib/ProductImage.php', 71 | 'PHPShopify\\ProductListing' => $vendorDir . '/phpclassic/php-shopify/lib/ProductListing.php', 72 | 'PHPShopify\\ProductVariant' => $vendorDir . '/phpclassic/php-shopify/lib/ProductVariant.php', 73 | 'PHPShopify\\Province' => $vendorDir . '/phpclassic/php-shopify/lib/Province.php', 74 | 'PHPShopify\\RecurringApplicationCharge' => $vendorDir . '/phpclassic/php-shopify/lib/RecurringApplicationCharge.php', 75 | 'PHPShopify\\Redirect' => $vendorDir . '/phpclassic/php-shopify/lib/Redirect.php', 76 | 'PHPShopify\\Refund' => $vendorDir . '/phpclassic/php-shopify/lib/Refund.php', 77 | 'PHPShopify\\Report' => $vendorDir . '/phpclassic/php-shopify/lib/Report.php', 78 | 'PHPShopify\\ScriptTag' => $vendorDir . '/phpclassic/php-shopify/lib/ScriptTag.php', 79 | 'PHPShopify\\ShippingZone' => $vendorDir . '/phpclassic/php-shopify/lib/ShippingZone.php', 80 | 'PHPShopify\\Shop' => $vendorDir . '/phpclassic/php-shopify/lib/Shop.php', 81 | 'PHPShopify\\ShopifyPayment' => $vendorDir . '/phpclassic/php-shopify/lib/ShopifyPayment.php', 82 | 'PHPShopify\\ShopifyResource' => $vendorDir . '/phpclassic/php-shopify/lib/ShopifyResource.php', 83 | 'PHPShopify\\ShopifySDK' => $vendorDir . '/phpclassic/php-shopify/lib/ShopifySDK.php', 84 | 'PHPShopify\\SmartCollection' => $vendorDir . '/phpclassic/php-shopify/lib/SmartCollection.php', 85 | 'PHPShopify\\TenderTransaction' => $vendorDir . '/phpclassic/php-shopify/lib/TenderTransaction.php', 86 | 'PHPShopify\\Theme' => $vendorDir . '/phpclassic/php-shopify/lib/Theme.php', 87 | 'PHPShopify\\Transaction' => $vendorDir . '/phpclassic/php-shopify/lib/Transaction.php', 88 | 'PHPShopify\\Transactions' => $vendorDir . '/phpclassic/php-shopify/lib/Transactions.php', 89 | 'PHPShopify\\UsageCharge' => $vendorDir . '/phpclassic/php-shopify/lib/UsageCharge.php', 90 | 'PHPShopify\\User' => $vendorDir . '/phpclassic/php-shopify/lib/User.php', 91 | 'PHPShopify\\Webhook' => $vendorDir . '/phpclassic/php-shopify/lib/Webhook.php', 92 | 'Symfony\\Polyfill\\Ctype\\Ctype' => $vendorDir . '/symfony/polyfill-ctype/Ctype.php', 93 | ); 94 | -------------------------------------------------------------------------------- /vendor/composer/autoload_files.php: -------------------------------------------------------------------------------- 1 | $vendorDir . '/symfony/polyfill-ctype/bootstrap.php', 10 | ); 11 | -------------------------------------------------------------------------------- /vendor/composer/autoload_namespaces.php: -------------------------------------------------------------------------------- 1 | array($vendorDir . '/symfony/polyfill-ctype'), 10 | 'PHPShopify\\' => array($vendorDir . '/phpclassic/php-shopify/lib'), 11 | 'Kirby\\' => array($vendorDir . '/getkirby/composer-installer/src'), 12 | 'Dotenv\\' => array($vendorDir . '/vlucas/phpdotenv/src'), 13 | ); 14 | -------------------------------------------------------------------------------- /vendor/composer/autoload_real.php: -------------------------------------------------------------------------------- 1 | = 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded()); 27 | if ($useStaticLoader) { 28 | require_once __DIR__ . '/autoload_static.php'; 29 | 30 | call_user_func(\Composer\Autoload\ComposerStaticInite4673e38b8d4402e7a200a551b4faac0::getInitializer($loader)); 31 | } else { 32 | $map = require __DIR__ . '/autoload_namespaces.php'; 33 | foreach ($map as $namespace => $path) { 34 | $loader->set($namespace, $path); 35 | } 36 | 37 | $map = require __DIR__ . '/autoload_psr4.php'; 38 | foreach ($map as $namespace => $path) { 39 | $loader->setPsr4($namespace, $path); 40 | } 41 | 42 | $classMap = require __DIR__ . '/autoload_classmap.php'; 43 | if ($classMap) { 44 | $loader->addClassMap($classMap); 45 | } 46 | } 47 | 48 | $loader->register(true); 49 | 50 | if ($useStaticLoader) { 51 | $includeFiles = Composer\Autoload\ComposerStaticInite4673e38b8d4402e7a200a551b4faac0::$files; 52 | } else { 53 | $includeFiles = require __DIR__ . '/autoload_files.php'; 54 | } 55 | foreach ($includeFiles as $fileIdentifier => $file) { 56 | composerRequiree4673e38b8d4402e7a200a551b4faac0($fileIdentifier, $file); 57 | } 58 | 59 | return $loader; 60 | } 61 | } 62 | 63 | function composerRequiree4673e38b8d4402e7a200a551b4faac0($fileIdentifier, $file) 64 | { 65 | if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) { 66 | require $file; 67 | 68 | $GLOBALS['__composer_autoload_files'][$fileIdentifier] = true; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /vendor/composer/autoload_static.php: -------------------------------------------------------------------------------- 1 | __DIR__ . '/..' . '/symfony/polyfill-ctype/bootstrap.php', 11 | ); 12 | 13 | public static $prefixLengthsPsr4 = array ( 14 | 'S' => 15 | array ( 16 | 'Symfony\\Polyfill\\Ctype\\' => 23, 17 | ), 18 | 'P' => 19 | array ( 20 | 'PHPShopify\\' => 11, 21 | ), 22 | 'K' => 23 | array ( 24 | 'Kirby\\' => 6, 25 | ), 26 | 'D' => 27 | array ( 28 | 'Dotenv\\' => 7, 29 | ), 30 | ); 31 | 32 | public static $prefixDirsPsr4 = array ( 33 | 'Symfony\\Polyfill\\Ctype\\' => 34 | array ( 35 | 0 => __DIR__ . '/..' . '/symfony/polyfill-ctype', 36 | ), 37 | 'PHPShopify\\' => 38 | array ( 39 | 0 => __DIR__ . '/..' . '/phpclassic/php-shopify/lib', 40 | ), 41 | 'Kirby\\' => 42 | array ( 43 | 0 => __DIR__ . '/..' . '/getkirby/composer-installer/src', 44 | ), 45 | 'Dotenv\\' => 46 | array ( 47 | 0 => __DIR__ . '/..' . '/vlucas/phpdotenv/src', 48 | ), 49 | ); 50 | 51 | public static $classMap = array ( 52 | 'Dotenv\\Dotenv' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Dotenv.php', 53 | 'Dotenv\\Exception\\ExceptionInterface' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/ExceptionInterface.php', 54 | 'Dotenv\\Exception\\InvalidCallbackException' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/InvalidCallbackException.php', 55 | 'Dotenv\\Exception\\InvalidFileException' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/InvalidFileException.php', 56 | 'Dotenv\\Exception\\InvalidPathException' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/InvalidPathException.php', 57 | 'Dotenv\\Exception\\ValidationException' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Exception/ValidationException.php', 58 | 'Dotenv\\Loader' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Loader.php', 59 | 'Dotenv\\Parser' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Parser.php', 60 | 'Dotenv\\Validator' => __DIR__ . '/..' . '/vlucas/phpdotenv/src/Validator.php', 61 | 'Kirby\\ComposerInstaller\\CmsInstaller' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/CmsInstaller.php', 62 | 'Kirby\\ComposerInstaller\\Installer' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/Installer.php', 63 | 'Kirby\\ComposerInstaller\\Plugin' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/Plugin.php', 64 | 'Kirby\\ComposerInstaller\\PluginInstaller' => __DIR__ . '/..' . '/getkirby/composer-installer/src/ComposerInstaller/PluginInstaller.php', 65 | 'PHPShopify\\AbandonedCheckout' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/AbandonedCheckout.php', 66 | 'PHPShopify\\ApplicationCharge' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ApplicationCharge.php', 67 | 'PHPShopify\\Article' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Article.php', 68 | 'PHPShopify\\Asset' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Asset.php', 69 | 'PHPShopify\\AuthHelper' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/AuthHelper.php', 70 | 'PHPShopify\\Balance' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Balance.php', 71 | 'PHPShopify\\Batch' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Batch.php', 72 | 'PHPShopify\\Blog' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Blog.php', 73 | 'PHPShopify\\CarrierService' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CarrierService.php', 74 | 'PHPShopify\\Collect' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Collect.php', 75 | 'PHPShopify\\Collection' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Collection.php', 76 | 'PHPShopify\\Comment' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Comment.php', 77 | 'PHPShopify\\Country' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Country.php', 78 | 'PHPShopify\\CurlRequest' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CurlRequest.php', 79 | 'PHPShopify\\CurlResponse' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CurlResponse.php', 80 | 'PHPShopify\\Currency' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Currency.php', 81 | 'PHPShopify\\CustomCollection' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CustomCollection.php', 82 | 'PHPShopify\\Customer' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Customer.php', 83 | 'PHPShopify\\CustomerAddress' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CustomerAddress.php', 84 | 'PHPShopify\\CustomerSavedSearch' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/CustomerSavedSearch.php', 85 | 'PHPShopify\\Discount' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Discount.php', 86 | 'PHPShopify\\DiscountCode' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/DiscountCode.php', 87 | 'PHPShopify\\Dispute' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Dispute.php', 88 | 'PHPShopify\\DraftOrder' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/DraftOrder.php', 89 | 'PHPShopify\\Event' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Event.php', 90 | 'PHPShopify\\Exception\\ApiException' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Exception/ApiException.php', 91 | 'PHPShopify\\Exception\\CurlException' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Exception/CurlException.php', 92 | 'PHPShopify\\Exception\\ResourceRateLimitException' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Exception/ResourceRateLimitException.php', 93 | 'PHPShopify\\Exception\\SdkException' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Exception/SdkException.php', 94 | 'PHPShopify\\Fulfillment' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Fulfillment.php', 95 | 'PHPShopify\\FulfillmentEvent' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/FulfillmentEvent.php', 96 | 'PHPShopify\\FulfillmentService' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/FulfillmentService.php', 97 | 'PHPShopify\\GiftCard' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/GiftCard.php', 98 | 'PHPShopify\\GraphQL' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/GraphQL.php', 99 | 'PHPShopify\\HttpRequestGraphQL' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/HttpRequestGraphQL.php', 100 | 'PHPShopify\\HttpRequestJson' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/HttpRequestJson.php', 101 | 'PHPShopify\\InventoryItem' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/InventoryItem.php', 102 | 'PHPShopify\\InventoryLevel' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/InventoryLevel.php', 103 | 'PHPShopify\\Location' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Location.php', 104 | 'PHPShopify\\Metafield' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Metafield.php', 105 | 'PHPShopify\\Multipass' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Multipass.php', 106 | 'PHPShopify\\Order' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Order.php', 107 | 'PHPShopify\\OrderRisk' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/OrderRisk.php', 108 | 'PHPShopify\\Page' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Page.php', 109 | 'PHPShopify\\Payouts' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Payouts.php', 110 | 'PHPShopify\\Policy' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Policy.php', 111 | 'PHPShopify\\PriceRule' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/PriceRule.php', 112 | 'PHPShopify\\Product' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Product.php', 113 | 'PHPShopify\\ProductImage' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ProductImage.php', 114 | 'PHPShopify\\ProductListing' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ProductListing.php', 115 | 'PHPShopify\\ProductVariant' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ProductVariant.php', 116 | 'PHPShopify\\Province' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Province.php', 117 | 'PHPShopify\\RecurringApplicationCharge' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/RecurringApplicationCharge.php', 118 | 'PHPShopify\\Redirect' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Redirect.php', 119 | 'PHPShopify\\Refund' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Refund.php', 120 | 'PHPShopify\\Report' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Report.php', 121 | 'PHPShopify\\ScriptTag' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ScriptTag.php', 122 | 'PHPShopify\\ShippingZone' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ShippingZone.php', 123 | 'PHPShopify\\Shop' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Shop.php', 124 | 'PHPShopify\\ShopifyPayment' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ShopifyPayment.php', 125 | 'PHPShopify\\ShopifyResource' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ShopifyResource.php', 126 | 'PHPShopify\\ShopifySDK' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/ShopifySDK.php', 127 | 'PHPShopify\\SmartCollection' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/SmartCollection.php', 128 | 'PHPShopify\\TenderTransaction' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/TenderTransaction.php', 129 | 'PHPShopify\\Theme' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Theme.php', 130 | 'PHPShopify\\Transaction' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Transaction.php', 131 | 'PHPShopify\\Transactions' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Transactions.php', 132 | 'PHPShopify\\UsageCharge' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/UsageCharge.php', 133 | 'PHPShopify\\User' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/User.php', 134 | 'PHPShopify\\Webhook' => __DIR__ . '/..' . '/phpclassic/php-shopify/lib/Webhook.php', 135 | 'Symfony\\Polyfill\\Ctype\\Ctype' => __DIR__ . '/..' . '/symfony/polyfill-ctype/Ctype.php', 136 | ); 137 | 138 | public static function getInitializer(ClassLoader $loader) 139 | { 140 | return \Closure::bind(function () use ($loader) { 141 | $loader->prefixLengthsPsr4 = ComposerStaticInite4673e38b8d4402e7a200a551b4faac0::$prefixLengthsPsr4; 142 | $loader->prefixDirsPsr4 = ComposerStaticInite4673e38b8d4402e7a200a551b4faac0::$prefixDirsPsr4; 143 | $loader->classMap = ComposerStaticInite4673e38b8d4402e7a200a551b4faac0::$classMap; 144 | 145 | }, null, ClassLoader::class); 146 | } 147 | } 148 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/AbandonedCheckout.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 9:50 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/abandoned_checkouts Shopify API Reference for Abandoned checkouts 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class AbandonedCheckout extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'checkout'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ApplicationCharge.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 9:50 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/applicationcharge Shopify API Reference for ApplicationCharge 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class ApplicationCharge extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'application_charge'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | 25 | // To activate ApplicationCharge 26 | protected $customPostActions = array( 27 | 'activate', 28 | ); 29 | } 30 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Article.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 3:18 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/article Shopify API Reference for Article 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Article -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Event $Event 18 | * @property-read Metafield $Metafield 19 | * 20 | * @method Event Event(integer $id = null) 21 | * @method Metafield Metafield(integer $id = null) 22 | * 23 | */ 24 | class Article extends ShopifyResource 25 | { 26 | /** 27 | * @inheritDoc 28 | */ 29 | protected $resourceKey = 'article'; 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | protected $childResource = array( 35 | 'Event', 36 | 'Metafield', 37 | ); 38 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Asset.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 3:39 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/asset Shopify API Reference for Asset 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Asset extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'asset'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/AuthHelper.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at: 8/27/16 10:58 AM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify; 9 | 10 | 11 | use PHPShopify\Exception\SdkException; 12 | 13 | class AuthHelper 14 | { 15 | /** 16 | * Get the url of the current page 17 | * 18 | * @return string 19 | */ 20 | public static function getCurrentUrl() 21 | { 22 | if (isset($_SERVER['HTTPS']) && 23 | ($_SERVER['HTTPS'] == 'on' || $_SERVER['HTTPS'] == 1) || 24 | isset($_SERVER['HTTP_X_FORWARDED_PROTO']) && 25 | $_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') { 26 | $protocol = 'https'; 27 | } 28 | else { 29 | $protocol = 'http'; 30 | } 31 | 32 | return "$protocol://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]"; 33 | } 34 | 35 | /** 36 | * Build a query string from a data array 37 | * This is a replacement for http_build_query because that returns an url-encoded string. 38 | * 39 | * @param array $data Data array 40 | * 41 | * @return array 42 | */ 43 | public static function buildQueryString($data) 44 | { 45 | $paramStrings = []; 46 | foreach ($data as $key => $value) { 47 | $paramStrings[] = "$key=$value"; 48 | } 49 | return join('&', $paramStrings); 50 | } 51 | 52 | /** 53 | * Verify if the request is made from shopify using hmac hash value 54 | * 55 | * @throws SdkException if SharedSecret is not provided or hmac is not found in the url parameters 56 | * 57 | * @return bool 58 | */ 59 | public static function verifyShopifyRequest() 60 | { 61 | $data = $_GET; 62 | 63 | if(!isset(ShopifySDK::$config['SharedSecret'])) { 64 | throw new SdkException("Please provide SharedSecret while configuring the SDK client."); 65 | } 66 | 67 | $sharedSecret = ShopifySDK::$config['SharedSecret']; 68 | 69 | //Get the hmac and remove it from array 70 | if (isset($data['hmac'])) { 71 | $hmac = $data['hmac']; 72 | unset($data['hmac']); 73 | } else { 74 | throw new SdkException("HMAC value not found in url parameters."); 75 | } 76 | //signature validation is deprecated 77 | if (isset($data['signature'])) { 78 | unset($data['signature']); 79 | } 80 | //Create data string for the remaining url parameters 81 | $dataString = self::buildQueryString($data); 82 | 83 | $realHmac = hash_hmac('sha256', $dataString, $sharedSecret); 84 | 85 | //hash the values before comparing (to prevent time attack) 86 | if(md5($realHmac) === md5($hmac)) { 87 | return true; 88 | } else { 89 | return false; 90 | } 91 | } 92 | 93 | /** 94 | * Redirect the user to the authorization page to allow the app access to the shop 95 | * 96 | * @see https://help.shopify.com/api/guides/authentication/oauth#scopes For allowed scopes 97 | * 98 | * @param string|string[] $scopes Scopes required by app 99 | * @param string $redirectUrl 100 | * @param string $state 101 | * @param string[] $options 102 | * @param bool $return If true, will return the authentical url instead of auto-redirecting to the page. 103 | * @throws SdkException if required configuration is not provided in $config 104 | * 105 | * @return void|string 106 | */ 107 | public static function createAuthRequest($scopes, $redirectUrl = null, $state = null, $options = null, $return = false) 108 | { 109 | $config = ShopifySDK::$config; 110 | 111 | if(!isset($config['ShopUrl']) || !isset($config['ApiKey'])) { 112 | throw new SdkException("ShopUrl and ApiKey are required for authentication request. Please check SDK configuration!"); 113 | } 114 | 115 | if (!$redirectUrl) { 116 | if(!isset($config['SharedSecret'])) { 117 | throw new SdkException("SharedSecret is required for getting access token. Please check SDK configuration!"); 118 | } 119 | 120 | //If redirect url is the same as this url, then need to check for access token when redirected back from shopify 121 | if(isset($_GET['code'])) { 122 | return self::getAccessToken($config); 123 | } else { 124 | $redirectUrl = self::getCurrentUrl(); 125 | } 126 | } 127 | 128 | if (is_array($scopes)) { 129 | $scopes = join(',', $scopes); 130 | } 131 | if(!empty($state)) { 132 | $state = '&state=' . $state; 133 | } 134 | if(!empty($options)) { 135 | $options = '&grant_options[]=' . join(',', $options); 136 | } 137 | // Official call structure 138 | // https://{shop}.myshopify.com/admin/oauth/authorize?client_id={api_key}&scope={scopes}&redirect_uri={redirect_uri}&state={nonce}&grant_options[]={option} 139 | $authUrl = $config['AdminUrl'] . 'oauth/authorize?client_id=' . $config['ApiKey'] . '&redirect_uri=' . $redirectUrl . "&scope=$scopes" . $state . $options; 140 | 141 | if ($return) { 142 | return $authUrl; 143 | } 144 | 145 | header("Location: $authUrl"); 146 | } 147 | 148 | /** 149 | * Get Access token for the API 150 | * Call this when being redirected from shopify page ( to the $redirectUrl) after authentication 151 | * 152 | * @throws SdkException if SharedSecret or ApiKey is missing in SDK configuration or request is not valid 153 | * 154 | * @return string 155 | */ 156 | public static function getAccessToken() 157 | { 158 | $config = ShopifySDK::$config; 159 | 160 | if(!isset($config['SharedSecret']) || !isset($config['ApiKey'])) { 161 | throw new SdkException("SharedSecret and ApiKey are required for getting access token. Please check SDK configuration!"); 162 | } 163 | 164 | if(self::verifyShopifyRequest()) { 165 | $data = array( 166 | 'client_id' => $config['ApiKey'], 167 | 'client_secret' => $config['SharedSecret'], 168 | 'code' => $_GET['code'], 169 | ); 170 | 171 | $response = HttpRequestJson::post($config['AdminUrl'] . 'oauth/access_token', $data); 172 | 173 | return isset($response['access_token']) ? $response['access_token'] : null; 174 | } else { 175 | throw new SdkException("This request is not initiated from a valid shopify shop!"); 176 | } 177 | } 178 | } 179 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Balance.php: -------------------------------------------------------------------------------- 1 | 5 | * @author Matthew Crigger 6 | * 7 | * @see https://help.shopify.com/en/api/reference/shopify_payments/balance Shopify API Reference for Shopify Payment Balance 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | /** 13 | * -------------------------------------------------------------------------- 14 | * ShopifyPayment -> Child Resources 15 | * -------------------------------------------------------------------------- 16 | * 17 | * 18 | */ 19 | class Balance extends ShopifyResource 20 | { 21 | /** 22 | * @inheritDoc 23 | */ 24 | protected $resourceKey = 'balance'; 25 | 26 | /** 27 | * Get the pluralized version of the resource key 28 | * 29 | * Normally its the same as $resourceKey appended with 's', when it's different, the specific resource class will override this function 30 | * 31 | * @return string 32 | */ 33 | protected function pluralizeKey() 34 | { 35 | return $this->resourceKey; 36 | } 37 | 38 | /** 39 | * If the resource is read only. (No POST / PUT / DELETE actions) 40 | * 41 | * @var boolean 42 | */ 43 | public $readOnly = true; 44 | 45 | /** 46 | * @inheritDoc 47 | */ 48 | protected $childResource = array( 49 | 'Transactions' 50 | ); 51 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Batch.php: -------------------------------------------------------------------------------- 1 | Batch action 12 | * -------------------------------------------------------------------------- 13 | * 14 | */ 15 | 16 | class Batch extends ShopifyResource 17 | { 18 | /** 19 | * @inheritDoc 20 | */ 21 | protected $resourceKey = 'batch'; 22 | 23 | protected function getResourcePath() 24 | { 25 | return $this->resourceKey; 26 | } 27 | 28 | protected function wrapData($dataArray, $dataKey = null) 29 | { 30 | return ['discount_codes' => $dataArray]; 31 | } 32 | 33 | } 34 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Blog.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 10:46 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/blog Shopify API Reference for Blog 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | /** 13 | * -------------------------------------------------------------------------- 14 | * Blog -> Child Resources 15 | * -------------------------------------------------------------------------- 16 | * @property-read Article $Article 17 | * @property-read Event $Event 18 | * @property-read Metafield $Metafield 19 | * 20 | * @method Article Article(integer $id = null) 21 | * @method Event Event(integer $id = null) 22 | * @method Metafield Metafield(integer $id = null) 23 | * 24 | */ 25 | class Blog extends ShopifyResource 26 | { 27 | /** 28 | * @inheritDoc 29 | */ 30 | public $resourceKey = 'blog'; 31 | 32 | /** 33 | * @inheritDoc 34 | */ 35 | protected $childResource = array( 36 | 'Article', 37 | 'Event', 38 | 'Metafield', 39 | ); 40 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/CarrierService.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:49 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/carrierservice Shopify API Reference for CarrierService 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class CarrierService extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'carrier_service'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Collect.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:54 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/collect Shopify API Reference for Collect 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Collect extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'collect'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Collection.php: -------------------------------------------------------------------------------- 1 | Child Resources 8 | * -------------------------------------------------------------------------- 9 | * 10 | * @property-read Product $Product 11 | * 12 | * @method Product Product(integer $id = null) 13 | * 14 | * @see https://shopify.dev/docs/admin-api/rest/reference/products/collection 15 | * 16 | */ 17 | class Collection extends ShopifyResource 18 | { 19 | /** 20 | * @inheritDoc 21 | */ 22 | public $readOnly = false; 23 | 24 | /** 25 | * @inheritDoc 26 | */ 27 | protected $resourceKey = 'collection'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $childResource = array( 33 | 'Product', 34 | ); 35 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Comment.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:58 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/comment Shopify API Reference for Comment 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * 15 | * -------------------------------------------------------------------------- 16 | * Comment -> Child Resources 17 | * -------------------------------------------------------------------------- 18 | * @property-read Event $Event 19 | * 20 | * @method Event Event(integer $id = null) 21 | * 22 | * -------------------------------------------------------------------------- 23 | * Comment -> Custom actions 24 | * -------------------------------------------------------------------------- 25 | * @method array markSpam() Mark a Comment as spam 26 | * @method array markNotSpam() Mark a Comment as not spam 27 | * @method array approve() Approve a Comment 28 | * @method array remove() Remove a Comment 29 | * @method array restore() Restore a Comment 30 | * 31 | */ 32 | class Comment extends ShopifyResource 33 | { 34 | /** 35 | * @inheritDoc 36 | */ 37 | protected $resourceKey = 'comment'; 38 | 39 | /** 40 | * @inheritDoc 41 | */ 42 | protected $childResource = array ( 43 | 'Event', 44 | ); 45 | 46 | /** 47 | * @inheritDoc 48 | */ 49 | protected $customPostActions = array( 50 | 'spam' => 'markSpam', 51 | 'not_spam' => 'markNotSpam', 52 | 'approve', 53 | 'remove', 54 | 'restore', 55 | ); 56 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Country.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 11:44 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/country Shopify API Reference for Country 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Country -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Province $Province 18 | * 19 | * @method Province Province(integer $id = null) 20 | * 21 | */ 22 | class Country extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | protected $resourceKey = 'country'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $childResource = array( 33 | 'Province', 34 | ); 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | protected function pluralizeKey() 40 | { 41 | return 'countries'; 42 | } 43 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/CurlRequest.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/17/16 2:50 PM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify; 9 | 10 | 11 | use PHPShopify\Exception\CurlException; 12 | use PHPShopify\Exception\ResourceRateLimitException; 13 | 14 | /* 15 | |-------------------------------------------------------------------------- 16 | | CurlRequest 17 | |-------------------------------------------------------------------------- 18 | | 19 | | This class handles get, post, put, delete HTTP requests 20 | | 21 | */ 22 | class CurlRequest 23 | { 24 | /** 25 | * HTTP Code of the last executed request 26 | * 27 | * @var integer 28 | */ 29 | public static $lastHttpCode; 30 | 31 | /** 32 | * HTTP response headers of last executed request 33 | * 34 | * @var array 35 | */ 36 | public static $lastHttpResponseHeaders = array(); 37 | 38 | /** 39 | * Initialize the curl resource 40 | * 41 | * @param string $url 42 | * @param array $httpHeaders 43 | * 44 | * @return resource 45 | */ 46 | protected static function init($url, $httpHeaders = array()) 47 | { 48 | // Create Curl resource 49 | $ch = curl_init(); 50 | 51 | // Set URL 52 | curl_setopt($ch, CURLOPT_URL, $url); 53 | 54 | //Return the transfer as a string 55 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 56 | 57 | curl_setopt($ch, CURLOPT_HEADER, true); 58 | curl_setopt($ch, CURLOPT_USERAGENT, 'PHPClassic/PHPShopify'); 59 | 60 | $headers = array(); 61 | foreach ($httpHeaders as $key => $value) { 62 | $headers[] = "$key: $value"; 63 | } 64 | //Set HTTP Headers 65 | curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); 66 | 67 | return $ch; 68 | 69 | } 70 | 71 | /** 72 | * Implement a GET request and return output 73 | * 74 | * @param string $url 75 | * @param array $httpHeaders 76 | * 77 | * @return string 78 | */ 79 | public static function get($url, $httpHeaders = array()) 80 | { 81 | //Initialize the Curl resource 82 | $ch = self::init($url, $httpHeaders); 83 | 84 | return self::processRequest($ch); 85 | } 86 | 87 | /** 88 | * Implement a POST request and return output 89 | * 90 | * @param string $url 91 | * @param array $data 92 | * @param array $httpHeaders 93 | * 94 | * @return string 95 | */ 96 | public static function post($url, $data, $httpHeaders = array()) 97 | { 98 | $ch = self::init($url, $httpHeaders); 99 | //Set the request type 100 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); 101 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 102 | 103 | return self::processRequest($ch); 104 | } 105 | 106 | /** 107 | * Implement a PUT request and return output 108 | * 109 | * @param string $url 110 | * @param array $data 111 | * @param array $httpHeaders 112 | * 113 | * @return string 114 | */ 115 | public static function put($url, $data, $httpHeaders = array()) 116 | { 117 | $ch = self::init($url, $httpHeaders); 118 | //set the request type 119 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT'); 120 | curl_setopt($ch, CURLOPT_POSTFIELDS, $data); 121 | 122 | return self::processRequest($ch); 123 | } 124 | 125 | /** 126 | * Implement a DELETE request and return output 127 | * 128 | * @param string $url 129 | * @param array $httpHeaders 130 | * 131 | * @return string 132 | */ 133 | public static function delete($url, $httpHeaders = array()) 134 | { 135 | $ch = self::init($url, $httpHeaders); 136 | //set the request type 137 | curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'DELETE'); 138 | 139 | return self::processRequest($ch); 140 | } 141 | 142 | /** 143 | * Execute a request, release the resource and return output 144 | * 145 | * @param resource $ch 146 | * 147 | * @throws CurlException if curl request is failed with error 148 | * 149 | * @return string 150 | */ 151 | protected static function processRequest($ch) 152 | { 153 | # Check for 429 leaky bucket error 154 | while (1) { 155 | $output = curl_exec($ch); 156 | $response = new CurlResponse($output); 157 | 158 | self::$lastHttpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); 159 | if (self::$lastHttpCode != 429) { 160 | break; 161 | } 162 | 163 | $limitHeader = explode('/', $response->getHeader('X-Shopify-Shop-Api-Call-Limit'), 2); 164 | 165 | if (isset($limitHeader[1]) && $limitHeader[0] < $limitHeader[1]) { 166 | throw new ResourceRateLimitException($response->getBody()); 167 | } 168 | 169 | $retryAfter = $response->getHeader('Retry-After'); 170 | 171 | if ($retryAfter === null) { 172 | break; 173 | } 174 | 175 | sleep((float)$retryAfter); 176 | } 177 | 178 | if (curl_errno($ch)) { 179 | throw new Exception\CurlException(curl_errno($ch) . ' : ' . curl_error($ch)); 180 | } 181 | 182 | // close curl resource to free up system resources 183 | curl_close($ch); 184 | 185 | self::$lastHttpResponseHeaders = $response->getHeaders(); 186 | 187 | return $response->getBody(); 188 | } 189 | 190 | } 191 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/CurlResponse.php: -------------------------------------------------------------------------------- 1 | parse($response); 15 | } 16 | 17 | /** 18 | * @param string $response 19 | */ 20 | private function parse($response) 21 | { 22 | $response = \explode("\r\n\r\n", $response); 23 | if (\count($response) > 1) { 24 | // We want the last two parts 25 | $response = \array_slice($response, -2, 2); 26 | list($headers, $body) = $response; 27 | foreach (\explode("\r\n", $headers) as $header) { 28 | $pair = \explode(': ', $header, 2); 29 | if (isset($pair[1])) { 30 | $headerKey = strtolower($pair[0]); 31 | $this->headers[$headerKey] = $pair[1]; 32 | } 33 | } 34 | } else { 35 | $body = $response[0]; 36 | } 37 | 38 | $this->body = $body; 39 | } 40 | 41 | /** 42 | * @return array 43 | */ 44 | public function getHeaders() 45 | { 46 | return $this->headers; 47 | } 48 | 49 | /** 50 | * @param string $key 51 | * 52 | * @return string 53 | */ 54 | public function getHeader($key) 55 | { 56 | $key = strtolower($key); 57 | return isset($this->headers[$key]) ? $this->headers[$key] : null; 58 | } 59 | 60 | /** 61 | * @return string 62 | */ 63 | public function getBody() 64 | { 65 | return $this->body; 66 | } 67 | 68 | public function __toString() 69 | { 70 | $body = $this->getBody(); 71 | $body = $body ? : ''; 72 | 73 | return $body; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Currency.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 11:46 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/customcollection Shopify API Reference for CustomCollection 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * CustomCollection -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Event $Event 18 | * @property-read Metafield $Metafield 19 | * 20 | * @method Event Event(integer $id = null) 21 | * @method Metafield Metafield(integer $id = null) 22 | * 23 | */ 24 | class CustomCollection extends ShopifyResource 25 | { 26 | /** 27 | * @inheritDoc 28 | */ 29 | protected $resourceKey = 'custom_collection'; 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | protected $childResource = array( 35 | 'Event', 36 | 'Metafield', 37 | ); 38 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Customer.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 11:47 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/customer Shopify API Reference for Customer 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Customer -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read CustomerAddress $Address 18 | * @property-read Metafield $Metafield 19 | * 20 | * @method CustomerAddress Address(integer $id = null) 21 | * @method Metafield Metafield(integer $id = null) 22 | * -------------------------------------------------------------------------- 23 | * Customer -> Custom actions 24 | * -------------------------------------------------------------------------- 25 | * @method array search(string $query = '') Search for customers matching supplied query 26 | */ 27 | class Customer extends ShopifyResource 28 | { 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $resourceKey ='customer'; 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | public $searchEnabled = true; 38 | 39 | /** 40 | * @inheritDoc 41 | */ 42 | protected $childResource = array( 43 | 'CustomerAddress' => 'Address', 44 | 'Metafield', 45 | 'Order' 46 | ); 47 | 48 | /** 49 | * Sends an account invite to a customer. 50 | * 51 | * @param array $customer_invite Customized invite data 52 | * 53 | * @return array 54 | */ 55 | public function send_invite($customer_invite = array()) 56 | { 57 | if (empty ( $customer_invite ) ) $customer_invite = new \stdClass(); 58 | $url = $this->generateUrl(array(), 'send_invite'); 59 | $dataArray = $this->wrapData($customer_invite, 'customer_invite'); 60 | 61 | return $this->post($dataArray, $url, false); 62 | } 63 | 64 | /** 65 | * Create account_activation_link for customer. 66 | * 67 | * @param array $customer_id 68 | * 69 | * @return array 70 | */ 71 | public function account_activation_url($customer_id = 0) 72 | { 73 | if (!(int)$customer_id > 0) { 74 | return false; 75 | } 76 | 77 | $url = $this->generateUrl(array(), $customer_id.'/account_activation_url'); 78 | return $this->post(array(), $url, false); 79 | } 80 | } 81 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/CustomerAddress.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 12:07 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/customeraddress Shopify API Reference for CustomerAddress 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * CustomerAddress -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array makeDefault() Sets the address as default for the customer 18 | * 19 | */ 20 | class CustomerAddress extends ShopifyResource 21 | { 22 | /** 23 | * @inheritDoc 24 | */ 25 | protected $resourceKey = 'address'; 26 | 27 | /** 28 | * @inheritDoc 29 | */ 30 | protected $customPutActions = array( 31 | 'default' => 'makeDefault', 32 | ); 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | protected function pluralizeKey() 38 | { 39 | return 'addresses'; 40 | } 41 | 42 | 43 | /** 44 | * Perform bulk operations against a number of addresses 45 | * 46 | * @param array $params 47 | * 48 | * @return array 49 | */ 50 | //TODO Issue (Getting Error from API) : Internal server error 51 | public function set($params) 52 | { 53 | $url = $this->generateUrl($params, 'set'); 54 | 55 | return $this->put(array(), $url); 56 | } 57 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/CustomerSavedSearch.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 2:07 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/customersavedsearch Shopify API Reference for CustomerSavedSearch 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * CustomerSavedSearch -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Customer $Customer 18 | * 19 | * @method Customer Customer(integer $id = null) 20 | * 21 | */ 22 | class CustomerSavedSearch extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | protected $resourceKey = 'customer_saved_search'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $childResource = array( 33 | 'Customer', 34 | ); 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | protected function pluralizeKey() 40 | { 41 | return 'customer_saved_searches'; 42 | } 43 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Discount.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 2:28 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/discount Shopify API Reference for Discount 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Discount -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array enable() Enable a discount 18 | * @method array disable() Disable a discount 19 | * 20 | */ 21 | class Discount extends ShopifyResource 22 | { 23 | /** 24 | * @inheritDoc 25 | */ 26 | protected $resourceKey = 'discount'; 27 | 28 | /** 29 | * @inheritDoc 30 | */ 31 | protected $customPostActions = array( 32 | 'enable', 33 | 'disable', 34 | ); 35 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/DiscountCode.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 5/06/19 2:09 AM UTC+03:00 6 | * 7 | * @see https://help.shopify.com/api/reference/discounts/discountcode Shopify API Reference for PriceRule 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * DiscountCode -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array lookup() Retrieves the location of a discount code. 18 | * 19 | */ 20 | 21 | class DiscountCode extends ShopifyResource 22 | { 23 | /** 24 | * @inheritDoc 25 | */ 26 | protected $resourceKey = 'discount_code'; 27 | 28 | /** 29 | * @inheritDoc 30 | */ 31 | protected $customGetActions = array( 32 | 'lookup', 33 | ); 34 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Dispute.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 01/06/2020 16:45 AM UTC+03:00 6 | * 7 | * @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments/dispute Shopify API Reference for Dispute 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * ShopifyPayment -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read ShopifyResource $DiscountCode 18 | * 19 | * @method ShopifyResource DiscountCode(integer $id = null) 20 | * 21 | */ 22 | class Dispute extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | public $resourceKey = 'dispute'; 28 | 29 | 30 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/DraftOrder.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/14/19 18:28 PM UTC+02:00 6 | * 7 | * @see https://help.shopify.com/api/reference/draftorder Shopify API Reference for DraftOrder 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | 14 | /** 15 | * -------------------------------------------------------------------------- 16 | * DraftOrder -> Custom actions 17 | * -------------------------------------------------------------------------- 18 | * @method array send_invoice() Send the invoice for a DraftOrder 19 | * @method array complete() Complete a DraftOrder 20 | * 21 | */ 22 | class DraftOrder extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | protected $resourceKey = 'draft_order'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $customPostActions = array( 33 | 'send_invoice', 34 | ); 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | protected $customPutActions = array( 40 | 'complete', 41 | ); 42 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Event.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at: 8/21/16 8:39 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/event/ Shopify API Reference for Event 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Event extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'event'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Exception/ApiException.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:28 AM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify\Exception; 9 | 10 | 11 | class ApiException extends \Exception 12 | { 13 | 14 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Exception/CurlException.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:26 AM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify\Exception; 9 | 10 | 11 | class CurlException extends \Exception 12 | { 13 | 14 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Exception/ResourceRateLimitException.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:29 AM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify\Exception; 9 | 10 | 11 | class SdkException extends \Exception 12 | { 13 | 14 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Fulfillment.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 3:04 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/fulfillment Shopify API Reference for Fulfillment 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Fulfillment -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Event $Event 18 | * 19 | * @method Event Event(integer $id = null) 20 | * 21 | * -------------------------------------------------------------------------- 22 | * Fulfillment -> Custom actions 23 | * -------------------------------------------------------------------------- 24 | * @method array complete() Complete a fulfillment 25 | * @method array open() Open a pending fulfillment 26 | * @method array cancel() Cancel a fulfillment 27 | * 28 | */ 29 | class Fulfillment extends ShopifyResource 30 | { 31 | /** 32 | * @inheritDoc 33 | */ 34 | protected $resourceKey = 'fulfillment'; 35 | 36 | /** 37 | * @inheritDoc 38 | */ 39 | protected $childResource = array( 40 | 'FulfillmentEvent' => 'Event', 41 | ); 42 | 43 | /** 44 | * @inheritDoc 45 | */ 46 | protected $customPostActions = array( 47 | 'complete', 48 | 'open', 49 | 'cancel', 50 | ); 51 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/FulfillmentEvent.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 4:49 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/fulfillmentevent Shopify API Reference for FulfillmentEvent 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class FulfillmentEvent extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'fulfillment_event'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public function getResourcePath() 24 | { 25 | return 'events'; 26 | } 27 | 28 | /** 29 | * @inheritDoc 30 | */ 31 | public function getResourcePostKey() 32 | { 33 | return 'event'; 34 | } 35 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/FulfillmentService.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 5:28 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/fulfillmentservice Shopify API Reference for FulfillmentService 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class FulfillmentService extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'fulfillment_service'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/GiftCard.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 5:35 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/gift_card Shopify API Reference for GiftCard 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * GiftCard -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array search() Search for gift cards matching supplied query 18 | * 19 | */ 20 | class GiftCard extends ShopifyResource 21 | { 22 | /** 23 | * @inheritDoc 24 | */ 25 | protected $resourceKey = 'gift_card'; 26 | 27 | /** 28 | * @inheritDoc 29 | */ 30 | public $searchEnabled = true; 31 | 32 | /** 33 | * Disable a gift card. 34 | * Disabling a gift card is permanent and cannot be undone. 35 | * 36 | * @return array 37 | */ 38 | public function disable() 39 | { 40 | $url = $this->generateUrl(array(), 'disable'); 41 | 42 | $dataArray = array( 43 | 'id' => $this->id, 44 | ); 45 | 46 | return $this->post($dataArray, $url); 47 | } 48 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/GraphQL.php: -------------------------------------------------------------------------------- 1 | generateUrl(); 46 | 47 | $response = HttpRequestGraphQL::post($url, $graphQL, $this->httpHeaders, $variables); 48 | 49 | return $this->processResponse($response); 50 | } 51 | 52 | /** 53 | * @inheritdoc 54 | * @throws SdkException 55 | */ 56 | public function get($urlParams = array(), $url = null, $dataKey = null) 57 | { 58 | throw new SdkException("Only POST method is allowed for GraphQL!"); 59 | } 60 | 61 | /** 62 | * @inheritdoc 63 | * @throws SdkException 64 | */ 65 | public function put($dataArray, $url = null, $wrapData = true) 66 | { 67 | throw new SdkException("Only POST method is allowed for GraphQL!"); 68 | } 69 | 70 | /** 71 | * @inheritdoc 72 | * @throws SdkException 73 | */ 74 | public function delete($urlParams = array(), $url = null) 75 | { 76 | throw new SdkException("Only POST method is allowed for GraphQL!"); 77 | } 78 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/HttpRequestGraphQL.php: -------------------------------------------------------------------------------- 1 | $data, 'variables' => $variables]); 51 | self::$httpHeaders['Content-type'] = 'application/json'; 52 | } else { 53 | self::$httpHeaders['Content-type'] = 'application/graphql'; 54 | } 55 | } 56 | 57 | /** 58 | * Implement a POST request and return json decoded output 59 | * 60 | * @param string $url 61 | * @param mixed $data 62 | * @param array $httpHeaders 63 | * @param array|null $variables 64 | * 65 | * @return string 66 | */ 67 | public static function post($url, $data, $httpHeaders = array(), $variables = null) 68 | { 69 | self::prepareRequest($httpHeaders, $data, $variables); 70 | 71 | $response = CurlRequest::post($url, self::$postDataGraphQL, self::$httpHeaders); 72 | 73 | return self::processResponse($response); 74 | } 75 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/HttpRequestJson.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at: 8/24/16 9:03 AM UTC+06:00 6 | */ 7 | 8 | namespace PHPShopify; 9 | 10 | /** 11 | * Class HttpRequestJson 12 | * 13 | * Prepare the data / headers for JSON requests, make the call and decode the response 14 | * Accepts data in array format returns data in array format 15 | * 16 | * @uses CurlRequest 17 | * 18 | * @package PHPShopify 19 | */ 20 | class HttpRequestJson 21 | { 22 | 23 | /** 24 | * HTTP request headers 25 | * 26 | * @var array 27 | */ 28 | protected static $httpHeaders; 29 | 30 | /** 31 | * Prepared JSON string to be posted with request 32 | * 33 | * @var string 34 | */ 35 | private static $postDataJSON; 36 | 37 | 38 | /** 39 | * Prepare the data and request headers before making the call 40 | * 41 | * @param array $httpHeaders 42 | * @param array $dataArray 43 | * 44 | * @return void 45 | */ 46 | protected static function prepareRequest($httpHeaders = array(), $dataArray = array()) 47 | { 48 | 49 | self::$postDataJSON = json_encode($dataArray); 50 | 51 | self::$httpHeaders = $httpHeaders; 52 | 53 | if (!empty($dataArray)) { 54 | self::$httpHeaders['Content-type'] = 'application/json'; 55 | self::$httpHeaders['Content-Length'] = strlen(self::$postDataJSON); 56 | } 57 | } 58 | 59 | /** 60 | * Implement a GET request and return json decoded output 61 | * 62 | * @param string $url 63 | * @param array $httpHeaders 64 | * 65 | * @return array 66 | */ 67 | public static function get($url, $httpHeaders = array()) 68 | { 69 | self::prepareRequest($httpHeaders); 70 | 71 | $response = CurlRequest::get($url, self::$httpHeaders); 72 | 73 | return self::processResponse($response); 74 | } 75 | 76 | /** 77 | * Implement a POST request and return json decoded output 78 | * 79 | * @param string $url 80 | * @param array $dataArray 81 | * @param array $httpHeaders 82 | * 83 | * @return array 84 | */ 85 | public static function post($url, $dataArray, $httpHeaders = array()) 86 | { 87 | self::prepareRequest($httpHeaders, $dataArray); 88 | 89 | $response = CurlRequest::post($url, self::$postDataJSON, self::$httpHeaders); 90 | 91 | return self::processResponse($response); 92 | } 93 | 94 | /** 95 | * Implement a PUT request and return json decoded output 96 | * 97 | * @param string $url 98 | * @param array $dataArray 99 | * @param array $httpHeaders 100 | * 101 | * @return array 102 | */ 103 | public static function put($url, $dataArray, $httpHeaders = array()) 104 | { 105 | self::prepareRequest($httpHeaders, $dataArray); 106 | 107 | $response = CurlRequest::put($url, self::$postDataJSON, self::$httpHeaders); 108 | 109 | return self::processResponse($response); 110 | } 111 | 112 | /** 113 | * Implement a DELETE request and return json decoded output 114 | * 115 | * @param string $url 116 | * @param array $httpHeaders 117 | * 118 | * @return array 119 | */ 120 | public static function delete($url, $httpHeaders = array()) 121 | { 122 | self::prepareRequest($httpHeaders); 123 | 124 | $response = CurlRequest::delete($url, self::$httpHeaders); 125 | 126 | return self::processResponse($response); 127 | } 128 | 129 | /** 130 | * Decode JSON response 131 | * 132 | * @param string $response 133 | * 134 | * @return array 135 | */ 136 | protected static function processResponse($response) 137 | { 138 | 139 | return json_decode($response, true); 140 | } 141 | 142 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/InventoryItem.php: -------------------------------------------------------------------------------- 1 | 4 | * Created at 04/15/18 02:25 PM UTC+03:00 5 | * 6 | * @see https://help.shopify.com/api/reference/inventoryitem 7 | */ 8 | 9 | namespace PHPShopify; 10 | 11 | class InventoryItem extends ShopifyResource 12 | { 13 | /** @inheritDoc */ 14 | protected $resourceKey = 'inventory_item'; 15 | } 16 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/InventoryLevel.php: -------------------------------------------------------------------------------- 1 | 4 | * Created at 04/15/18 02:31 PM UTC+03:00 5 | * 6 | * @see https://help.shopify.com/api/reference/inventorylevel 7 | */ 8 | 9 | namespace PHPShopify; 10 | 11 | /** 12 | * Class InventoryLevel 13 | * 14 | * @method array adjust($data) Adjust inventory level. 15 | * @method array connect($data) Connect an inventory item to a location. 16 | * @method array set($data) Sets an inventory level for a single inventory item within a location. 17 | */ 18 | class InventoryLevel extends ShopifyResource 19 | { 20 | /** @inheritDoc */ 21 | protected $resourceKey = 'inventory_level'; 22 | 23 | /** @inheritDoc */ 24 | protected $customPostActions = [ 25 | 'adjust', 26 | 'connect', 27 | 'set', 28 | ]; 29 | } 30 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Location.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 5:47 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/location Shopify API Reference for Location 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Location extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'location'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public $readOnly = true; 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | protected $childResource = array( 34 | 'InventoryLevel', 35 | ); 36 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Metafield.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 5:51 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/metafield Shopify API Reference for Metafield 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Metafield extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'metafield'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Multipass.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 6:05 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/multipass Shopify API Reference for Multipass 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | use PHPShopify\Exception\ApiException; 14 | 15 | class Multipass extends ShopifyResource 16 | { 17 | 18 | /** 19 | * Multipass constructor. 20 | * 21 | * @param integer $id 22 | * 23 | * @throws ApiException 24 | */ 25 | public function __construct($id = null) 26 | { 27 | throw new ApiException("Multipass API is not available yet!"); 28 | } 29 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Order.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 2:59 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/order Shopify API Reference for Order 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | 14 | /** 15 | * -------------------------------------------------------------------------- 16 | * Order -> Child Resources 17 | * -------------------------------------------------------------------------- 18 | * @property-read Fulfillment $Fulfillment 19 | * @property-read OrderRisk $Risk 20 | * @property-read Refund $Refund 21 | * @property-read Transaction $Transaction 22 | * @property-read Event $Event 23 | * @property-read Metafield $Metafield 24 | * 25 | * @method Fulfillment Fulfillment(integer $id = null) 26 | * @method OrderRisk Risk(integer $id = null) 27 | * @method Refund Refund(integer $id = null) 28 | * @method Transaction Transaction(integer $id = null) 29 | * @method Event Event(integer $id = null) 30 | * @method Metafield Metafield(integer $id = null) 31 | * 32 | * -------------------------------------------------------------------------- 33 | * Order -> Custom actions 34 | * -------------------------------------------------------------------------- 35 | * @method array close() Close an Order 36 | * @method array open() Re-open a closed Order 37 | * @method array cancel(array $data) Cancel an Order 38 | * 39 | */ 40 | class Order extends ShopifyResource 41 | { 42 | /** 43 | * @inheritDoc 44 | */ 45 | protected $resourceKey = 'order'; 46 | 47 | /** 48 | * @inheritDoc 49 | */ 50 | protected $childResource = array ( 51 | 'Fulfillment', 52 | 'OrderRisk' => 'Risk', 53 | 'Refund', 54 | 'Transaction', 55 | 'Event', 56 | 'Metafield', 57 | ); 58 | 59 | /** 60 | * @inheritDoc 61 | */ 62 | protected $customPostActions = array( 63 | 'close', 64 | 'open', 65 | 'cancel', 66 | ); 67 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/OrderRisk.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 6:10 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/order_risks Shopify API Reference for Order Risks 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class OrderRisk extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'risk'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Page.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/17/16 10:39 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/page Shopify API Reference for Page 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Page -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Event $Event 18 | * @property-read Metafield $Metafield 19 | * 20 | * @method Event Event(integer $id = null) 21 | * @method Metafield Metafield(integer $id = null) 22 | * 23 | */ 24 | class Page extends ShopifyResource 25 | { 26 | /** 27 | * @inheritDoc 28 | */ 29 | protected $resourceKey = 'page'; 30 | 31 | /** 32 | * @inheritDoc 33 | */ 34 | protected $childResource = array( 35 | 'Event', 36 | 'Metafield', 37 | ); 38 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Payouts.php: -------------------------------------------------------------------------------- 1 | 5 | * @author Matthew Crigger 6 | * 7 | * @see https://help.shopify.com/en/api/reference/shopify_payments/payout Shopify API Reference for Shopify Payment Payouts 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | /** 13 | * -------------------------------------------------------------------------- 14 | * ShopifyPayment -> Child Resources 15 | * -------------------------------------------------------------------------- 16 | * 17 | * 18 | */ 19 | class Payouts extends ShopifyResource 20 | { 21 | /** 22 | * @inheritDoc 23 | */ 24 | protected $resourceKey = 'payout'; 25 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Policy.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 6:22 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/policy Shopify API Reference for Policy 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Policy extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'policy'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public $readOnly = true; 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | public function pluralizeKey() 34 | { 35 | return 'policies'; 36 | } 37 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/PriceRule.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 5/06/19 2:06 AM UTC+03:00 6 | * 7 | * @see https://help.shopify.com/api/reference/discounts/pricerule Shopify API Reference for PriceRule 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * PriceRule -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read ShopifyResource $DiscountCode 18 | * 19 | * @method ShopifyResource DiscountCode(integer $id = null) 20 | * @method ShopifyResource Batch() 21 | * 22 | */ 23 | class PriceRule extends ShopifyResource 24 | { 25 | /** 26 | * @inheritDoc 27 | */ 28 | public $resourceKey = 'price_rule'; 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | protected $childResource = array( 34 | 'DiscountCode', 35 | 'Batch', 36 | ); 37 | } 38 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Product.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 10:46 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/product Shopify API Reference for Product 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Product -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read ProductImage $Image 18 | * @property-read ProductVariant $Variant 19 | * @property-read Metafield $Metafield 20 | * @property-read Event $Event 21 | * 22 | * @method ProductImage Image(integer $id = null) 23 | * @method ProductVariant Variant(integer $id = null) 24 | * @method Metafield Metafield(integer $id = null) 25 | * @method Event Event(integer $id = null) 26 | * 27 | */ 28 | class Product extends ShopifyResource 29 | { 30 | /** 31 | * @inheritDoc 32 | */ 33 | public $resourceKey = 'product'; 34 | 35 | /** 36 | * @inheritDoc 37 | */ 38 | protected $childResource = array( 39 | 'ProductImage' => 'Image', 40 | 'ProductVariant' => 'Variant', 41 | 'Metafield', 42 | 'Event' 43 | ); 44 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ProductImage.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 1:35 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/product_image Shopify API Reference for Product Image 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class ProductImage extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'image'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ProductListing.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at: 6/2/18 1:38 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/sales_channels/productlisting Shopify API Reference for Shipping Zone 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class ProductListing extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'product_listing'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | protected $customGetActions = array ( 24 | 'product_ids' => 'productIds', 25 | ); 26 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ProductVariant.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 1:50 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/product_variant Shopify API Reference for Product Variant 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * ProductVariant -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Metafield $Metafield 18 | * 19 | * @method Metafield Metafield(integer $id = null) 20 | * 21 | */ 22 | class ProductVariant extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | protected $resourceKey = 'variant'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | public $searchEnabled = true; 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | protected $childResource = array( 38 | 'Metafield', 39 | ); 40 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Province.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 6:25 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/province Shopify API Reference for Province 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Province extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'province'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/RecurringApplicationCharge.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 6:30 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/recurringapplicationcharge Shopify API Reference for RecurringApplicationCharge 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * RecurringApplicationCharge -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read UsageCharge $UsageCharge 18 | * 19 | * @method UsageCharge UsageCharge(integer $id = null) 20 | * 21 | * -------------------------------------------------------------------------- 22 | * RecurringApplicationCharge -> Custom actions 23 | * -------------------------------------------------------------------------- 24 | * @method array activate() Activate a recurring application charge 25 | * 26 | */ 27 | class RecurringApplicationCharge extends ShopifyResource 28 | { 29 | /** 30 | * @inheritDoc 31 | */ 32 | protected $resourceKey = 'recurring_application_charge'; 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | public $countEnabled = false; 38 | 39 | /** 40 | * @inheritDoc 41 | */ 42 | protected $childResource = array( 43 | 'UsageCharge', 44 | ); 45 | 46 | /** 47 | * @inheritDoc 48 | */ 49 | protected $customPostActions = array( 50 | 'activate', 51 | ); 52 | 53 | /* 54 | * Customize a recurring application charge 55 | * 56 | * @param array $data 57 | * 58 | * @return array 59 | * 60 | */ 61 | public function customize($dataArray) 62 | { 63 | $dataArray = $this->wrapData($dataArray); 64 | 65 | $url = $this->generateUrl($dataArray, 'customize'); 66 | 67 | return $this->put(array(), $url); 68 | } 69 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Redirect.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:13 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/redirect Shopify API Reference for Redirect 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Redirect extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'redirect'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Refund.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:19 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/refund Shopify API Reference for Refund 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Refund -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array calculate(array $calculation = null) Calculate a Refund. 18 | * 19 | */ 20 | class Refund extends ShopifyResource 21 | { 22 | /** 23 | * @inheritDoc 24 | */ 25 | protected $resourceKey = 'refund'; 26 | 27 | /** 28 | * @inheritDoc 29 | */ 30 | protected $customPostActions = array ( 31 | 'calculate', 32 | ); 33 | } 34 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Report.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/17/16 4:46 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/scripttag Shopify API Reference for ScriptTag 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class ScriptTag extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'script_tag'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ShippingZone.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:36 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/shipping_zone Shopify API Reference for Shipping Zone 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class ShippingZone extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'shipping_zone'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public $readOnly = true; 29 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Shop.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 10:42 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/shop Shopify API Reference for Shop 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Shop extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'shop'; 19 | 20 | /** 21 | * @inheritDoc 22 | */ 23 | public $countEnabled = false; 24 | 25 | /** 26 | * @inheritDoc 27 | */ 28 | public $readOnly = true; 29 | 30 | /** 31 | * @inheritDoc 32 | */ 33 | public function pluralizeKey() 34 | { 35 | //Only one shop object for each store. So no pluralize 36 | return 'shop'; 37 | } 38 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ShopifyPayment.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 01/06/2020 16:45 AM UTC+03:00 6 | * 7 | * @see https://shopify.dev/docs/admin-api/rest/reference/shopify_payments Shopify API Reference for ShopifyPayment 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * ShopifyPayment -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read ShopifyResource $Dispute 18 | * 19 | * @method ShopifyResource Dispute(integer $id = null) 20 | * 21 | * @property-read ShopifyResource $Balance 22 | * 23 | * @method ShopifyResource Balance(integer $id = null) 24 | * 25 | * @property-read ShopifyResource $Payouts 26 | * 27 | * @method ShopifyResource Payouts(integer $id = null) 28 | * 29 | 30 | */ 31 | class ShopifyPayment extends ShopifyResource 32 | { 33 | /** 34 | * @inheritDoc 35 | */ 36 | public $resourceKey = 'shopify_payment'; 37 | 38 | /** 39 | * If the resource is read only. (No POST / PUT / DELETE actions) 40 | * 41 | * @var boolean 42 | */ 43 | public $readOnly = true; 44 | 45 | /** 46 | * @inheritDoc 47 | */ 48 | protected $childResource = array( 49 | 'Balance', 50 | 'Dispute', 51 | 'Payouts', 52 | ); 53 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/ShopifySDK.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/16/16 10:42 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/ Shopify API Reference 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /* 14 | |-------------------------------------------------------------------------- 15 | | Shopify API SDK Client Class 16 | |-------------------------------------------------------------------------- 17 | | 18 | | This class initializes the resource objects 19 | | 20 | | Usage: 21 | | //For private app 22 | | $config = array( 23 | | 'ShopUrl' => 'yourshop.myshopify.com', 24 | | 'ApiKey' => '***YOUR-PRIVATE-API-KEY***', 25 | | 'Password' => '***YOUR-PRIVATE-API-PASSWORD***', 26 | | ); 27 | | //For third party app 28 | | $config = array( 29 | | 'ShopUrl' => 'yourshop.myshopify.com', 30 | | 'AccessToken' => '***ACCESS-TOKEN-FOR-THIRD-PARTY-APP***', 31 | | ); 32 | | //Create the shopify client object 33 | | $shopify = new ShopifySDK($config); 34 | | 35 | | //Get shop details 36 | | $products = $shopify->Shop->get(); 37 | | 38 | | //Get list of all products 39 | | $products = $shopify->Product->get(); 40 | | 41 | | //Get a specific product by product ID 42 | | $products = $shopify->Product($productID)->get(); 43 | | 44 | | //Update a product 45 | | $updateInfo = array('title' => 'New Product Title'); 46 | | $products = $shopify->Product($productID)->put($updateInfo); 47 | | 48 | | //Delete a product 49 | | $products = $shopify->Product($productID)->delete(); 50 | | 51 | | //Create a new product 52 | | $productInfo = array( 53 | | "title" => "Burton Custom Freestlye 151", 54 | | "body_html" => "Good snowboard!<\/strong>", 55 | | "vendor" => "Burton", 56 | | "product_type" => "Snowboard", 57 | | ); 58 | | $products = $shopify->Product->post($productInfo); 59 | | 60 | | //Get variants of a product (using Child resource) 61 | | $products = $shopify->Product($productID)->Variant->get(); 62 | | 63 | | //GraphQL 64 | | $data = $shopify->GraphQL->post($graphQL); 65 | | 66 | */ 67 | use PHPShopify\Exception\SdkException; 68 | 69 | /** 70 | * @property-read AbandonedCheckout $AbandonedCheckout 71 | * @property-read ApplicationCharge $ApplicationCharge 72 | * @property-read Blog $Blog 73 | * @property-read CarrierService $CarrierService 74 | * @property-read Collect $Collect 75 | * @property-read Collection $Collection 76 | * @property-read Comment $Comment 77 | * @property-read Country $Country 78 | * @property-read Currency $Currency 79 | * @property-read CustomCollection $CustomCollection 80 | * @property-read Customer $Customer 81 | * @property-read CustomerSavedSearch $CustomerSavedSearch 82 | * @property-read Discount $Discount 83 | * @property-read DiscountCode $DiscountCode 84 | * @property-read DraftOrder $DraftOrder 85 | * @property-read Event $Event 86 | * @property-read FulfillmentService $FulfillmentService 87 | * @property-read GiftCard $GiftCard 88 | * @property-read InventoryItem $InventoryItem 89 | * @property-read InventoryLevel $InventoryLevel 90 | * @property-read Location $Location 91 | * @property-read Metafield $Metafield 92 | * @property-read Multipass $Multipass 93 | * @property-read Order $Order 94 | * @property-read Page $Page 95 | * @property-read Policy $Policy 96 | * @property-read Product $Product 97 | * @property-read ProductListing $ProductListing 98 | * @property-read ProductVariant $ProductVariant 99 | * @property-read PriceRule $PriceRule 100 | * @property-read RecurringApplicationCharge $RecurringApplicationCharge 101 | * @property-read Redirect $Redirect 102 | * @property-read Report $Report 103 | * @property-read ScriptTag $ScriptTag 104 | * @property-read ShippingZone $ShippingZone 105 | * @property-read Shop $Shop 106 | * @property-read SmartCollection $SmartCollection 107 | * @property-read ShopifyPayment $ShopifyPayment 108 | * @property-read TenderTransaction $TenderTransaction 109 | * @property-read Theme $Theme 110 | * @property-read User $User 111 | * @property-read Webhook $Webhook 112 | * @property-read GraphQL $GraphQL 113 | * 114 | * @method AbandonedCheckout AbandonedCheckout(integer $id = null) 115 | * @method ApplicationCharge ApplicationCharge(integer $id = null) 116 | * @method Blog Blog(integer $id = null) 117 | * @method CarrierService CarrierService(integer $id = null) 118 | * @method Collect Collect(integer $id = null) 119 | * @method Collection Collection(integer $id = null) 120 | * @method Comment Comment(integer $id = null) 121 | * @method Country Country(integer $id = null) 122 | * @method Currency Currency(integer $id = null) 123 | * @method CustomCollection CustomCollection(integer $id = null) 124 | * @method Customer Customer(integer $id = null) 125 | * @method CustomerSavedSearch CustomerSavedSearch(integer $id = null) 126 | * @method Discount Discount(integer $id = null) 127 | * @method DraftOrder DraftOrder(integer $id = null) 128 | * @method DiscountCode DiscountCode(integer $id = null) 129 | * @method Event Event(integer $id = null) 130 | * @method FulfillmentService FulfillmentService(integer $id = null) 131 | * @method GiftCard GiftCard(integer $id = null) 132 | * @method InventoryItem InventoryItem(integer $id = null) 133 | * @method InventoryLevel InventoryLevel(integer $id = null) 134 | * @method Location Location(integer $id = null) 135 | * @method Metafield Metafield(integer $id = null) 136 | * @method Multipass Multipass(integer $id = null) 137 | * @method Order Order(integer $id = null) 138 | * @method Page Page(integer $id = null) 139 | * @method Policy Policy(integer $id = null) 140 | * @method Product Product(integer $id = null) 141 | * @method ProductListing ProductListing(integer $id = null) 142 | * @method ProductVariant ProductVariant(integer $id = null) 143 | * @method PriceRule PriceRule(integer $id = null) 144 | * @method RecurringApplicationCharge RecurringApplicationCharge(integer $id = null) 145 | * @method Redirect Redirect(integer $id = null) 146 | * @method Report Report(integer $id = null) 147 | * @method ScriptTag ScriptTag(integer $id = null) 148 | * @method ShippingZone ShippingZone(integer $id = null) 149 | * @method Shop Shop(integer $id = null) 150 | * @method ShopifyPayment ShopifyPayment() 151 | * @method SmartCollection SmartCollection(integer $id = null) 152 | * @method TenderTransaction TenderTransaction() 153 | * @method Theme Theme(int $id = null) 154 | * @method User User(integer $id = null) 155 | * @method Webhook Webhook(integer $id = null) 156 | * @method GraphQL GraphQL() 157 | */ 158 | class ShopifySDK 159 | { 160 | /** 161 | * List of available resources which can be called from this client 162 | * 163 | * @var string[] 164 | */ 165 | protected $resources = array( 166 | 'AbandonedCheckout', 167 | 'ApplicationCharge', 168 | 'Blog', 169 | 'CarrierService', 170 | 'Collect', 171 | 'Collection', 172 | 'Comment', 173 | 'Country', 174 | 'Currency', 175 | 'CustomCollection', 176 | 'Customer', 177 | 'CustomerSavedSearch', 178 | 'Discount', 179 | 'DiscountCode', 180 | 'DraftOrder', 181 | 'Event', 182 | 'FulfillmentService', 183 | 'GiftCard', 184 | 'InventoryItem', 185 | 'InventoryLevel', 186 | 'Location', 187 | 'Metafield', 188 | 'Multipass', 189 | 'Order', 190 | 'Page', 191 | 'Policy', 192 | 'Product', 193 | 'ProductListing', 194 | 'ProductVariant', 195 | 'PriceRule', 196 | 'RecurringApplicationCharge', 197 | 'Redirect', 198 | 'Report', 199 | 'ScriptTag', 200 | 'ShippingZone', 201 | 'Shop', 202 | 'SmartCollection', 203 | 'ShopifyPayment', 204 | 'TenderTransaction', 205 | 'Theme', 206 | 'User', 207 | 'Webhook', 208 | 'GraphQL' 209 | ); 210 | 211 | /** 212 | * @var float microtime of last api call 213 | */ 214 | public static $microtimeOfLastApiCall; 215 | 216 | /** 217 | * @var float Minimum gap in seconds to maintain between 2 api calls 218 | */ 219 | public static $timeAllowedForEachApiCall = .5; 220 | 221 | /** 222 | * @var string Default Shopify API version 223 | */ 224 | public static $defaultApiVersion = '2020-01'; 225 | 226 | /** 227 | * Shop / API configurations 228 | * 229 | * @var array 230 | */ 231 | public static $config = array( 232 | ); 233 | 234 | /** 235 | * List of resources which are only available through a parent resource 236 | * 237 | * @var array Array key is the child resource name and array value is the parent resource name 238 | */ 239 | protected $childResources = array( 240 | 'Article' => 'Blog', 241 | 'Asset' => 'Theme', 242 | 'Balance' => 'ShopifyPayment', 243 | 'CustomerAddress' => 'Customer', 244 | 'Dispute' => 'ShopifyPayment', 245 | 'Fulfillment' => 'Order', 246 | 'FulfillmentEvent' => 'Fulfillment', 247 | 'OrderRisk' => 'Order', 248 | 'Payouts' => 'ShopifyPayment', 249 | 'ProductImage' => 'Product', 250 | 'ProductVariant' => 'Product', 251 | 'DiscountCode' => 'PriceRule', 252 | 'Province' => 'Country', 253 | 'Refund' => 'Order', 254 | 'Transaction' => 'Order', 255 | 'Transactions' => 'Balance', 256 | 'UsageCharge' => 'RecurringApplicationCharge', 257 | ); 258 | 259 | /* 260 | * ShopifySDK constructor 261 | * 262 | * @param array $config 263 | * 264 | * @return void 265 | */ 266 | public function __construct($config = array()) 267 | { 268 | if(!empty($config)) { 269 | ShopifySDK::config($config); 270 | } 271 | } 272 | 273 | /** 274 | * Return ShopifyResource instance for a resource. 275 | * @example $shopify->Product->get(); //Returns all available Products 276 | * Called like an object properties (without parenthesis) 277 | * 278 | * @param string $resourceName 279 | * 280 | * @return ShopifyResource 281 | */ 282 | public function __get($resourceName) 283 | { 284 | return $this->$resourceName(); 285 | } 286 | 287 | /** 288 | * Return ShopifyResource instance for a resource. 289 | * Called like an object method (with parenthesis) optionally with the resource ID as the first argument 290 | * @example $shopify->Product($productID); //Return a specific product defined by $productID 291 | * 292 | * @param string $resourceName 293 | * @param array $arguments 294 | * 295 | * @throws SdkException if the $name is not a valid ShopifyResource resource. 296 | * 297 | * @return ShopifyResource 298 | */ 299 | public function __call($resourceName, $arguments) 300 | { 301 | if (!in_array($resourceName, $this->resources)) { 302 | if (isset($this->childResources[$resourceName])) { 303 | $message = "$resourceName is a child resource of " . $this->childResources[$resourceName] . ". Cannot be accessed directly."; 304 | } else { 305 | $message = "Invalid resource name $resourceName. Pls check the API Reference to get the appropriate resource name."; 306 | } 307 | throw new SdkException($message); 308 | } 309 | 310 | $resourceClassName = __NAMESPACE__ . "\\$resourceName"; 311 | 312 | //If first argument is provided, it will be considered as the ID of the resource. 313 | $resourceID = !empty($arguments) ? $arguments[0] : null; 314 | 315 | //Initiate the resource object 316 | $resource = new $resourceClassName($resourceID); 317 | 318 | return $resource; 319 | } 320 | 321 | /** 322 | * Configure the SDK client 323 | * 324 | * @param array $config 325 | * 326 | * @return ShopifySDK 327 | */ 328 | public static function config($config) 329 | { 330 | /** 331 | * Reset config to it's initial values 332 | */ 333 | self::$config = array( 334 | 'ApiVersion' => self::$defaultApiVersion 335 | ); 336 | 337 | foreach ($config as $key => $value) { 338 | self::$config[$key] = $value; 339 | } 340 | 341 | //Re-set the admin url if shop url is changed 342 | if(isset($config['ShopUrl'])) { 343 | self::setAdminUrl(); 344 | } 345 | 346 | //If want to keep more wait time than .5 seconds for each call 347 | if (isset($config['AllowedTimePerCall'])) { 348 | static::$timeAllowedForEachApiCall = $config['AllowedTimePerCall']; 349 | } 350 | 351 | return new ShopifySDK; 352 | } 353 | 354 | /** 355 | * Set the admin url, based on the configured shop url 356 | * 357 | * @return string 358 | */ 359 | public static function setAdminUrl() 360 | { 361 | $shopUrl = self::$config['ShopUrl']; 362 | 363 | //Remove https:// and trailing slash (if provided) 364 | $shopUrl = preg_replace('#^https?://|/$#', '', $shopUrl); 365 | $apiVersion = self::$config['ApiVersion']; 366 | 367 | if(isset(self::$config['ApiKey']) && isset(self::$config['Password'])) { 368 | $apiKey = self::$config['ApiKey']; 369 | $apiPassword = self::$config['Password']; 370 | $adminUrl = "https://$apiKey:$apiPassword@$shopUrl/admin/"; 371 | } else { 372 | $adminUrl = "https://$shopUrl/admin/"; 373 | } 374 | 375 | self::$config['AdminUrl'] = $adminUrl; 376 | self::$config['ApiUrl'] = $adminUrl . "api/$apiVersion/"; 377 | 378 | return $adminUrl; 379 | } 380 | 381 | /** 382 | * Get the admin url of the configured shop 383 | * 384 | * @return string 385 | */ 386 | public static function getAdminUrl() { 387 | return self::$config['AdminUrl']; 388 | } 389 | 390 | /** 391 | * Get the api url of the configured shop 392 | * 393 | * @return string 394 | */ 395 | public static function getApiUrl() { 396 | return self::$config['ApiUrl']; 397 | } 398 | 399 | /** 400 | * Maintain maximum 2 calls per second to the API 401 | * 402 | * @see https://help.shopify.com/api/guides/api-call-limit 403 | * 404 | * @param bool $firstCallWait Whether to maintain the wait time even if it is the first API call 405 | */ 406 | public static function checkApiCallLimit($firstCallWait = false) 407 | { 408 | $timeToWait = 0; 409 | if (static::$microtimeOfLastApiCall == null) { 410 | if ($firstCallWait) { 411 | $timeToWait = static::$timeAllowedForEachApiCall; 412 | } 413 | } else { 414 | $now = microtime(true); 415 | $timeSinceLastCall = $now - static::$microtimeOfLastApiCall; 416 | //Ensure 2 API calls per second 417 | if($timeSinceLastCall < static::$timeAllowedForEachApiCall) { 418 | $timeToWait = static::$timeAllowedForEachApiCall - $timeSinceLastCall; 419 | } 420 | } 421 | 422 | if ($timeToWait) { 423 | //convert time to microseconds 424 | $microSecondsToWait = $timeToWait * 1000000; 425 | //Wait to maintain the API call difference of .5 seconds 426 | usleep($microSecondsToWait); 427 | } 428 | 429 | static::$microtimeOfLastApiCall = microtime(true); 430 | } 431 | } 432 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/SmartCollection.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:40 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/smartcollection Shopify API Reference for SmartCollection 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * SmartCollection -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Event $Event 18 | * 19 | * @method Event Event(integer $id = null) 20 | * 21 | * -------------------------------------------------------------------------- 22 | * SmartCollection -> Custom actions 23 | * -------------------------------------------------------------------------- 24 | * 25 | */ 26 | class SmartCollection extends ShopifyResource 27 | { 28 | /** 29 | * @inheritDoc 30 | */ 31 | protected $resourceKey = 'smart_collection'; 32 | 33 | /** 34 | * @inheritDoc 35 | */ 36 | protected $childResource = array( 37 | 'Event', 38 | 'Metafield', 39 | ); 40 | 41 | /** 42 | * Set the ordering type and/or the manual order of products in a smart collection 43 | * 44 | * @param array $params 45 | * 46 | * @return array 47 | */ 48 | public function sortOrder($params) 49 | { 50 | $url = $this->generateUrl($params, 'order'); 51 | 52 | return $this->put(array(), $url); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/TenderTransaction.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/18/16 10:46 AM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/theme Shopify API Reference for Theme 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * Theme -> Child Resources 16 | * -------------------------------------------------------------------------- 17 | * @property-read Asset $Asset 18 | * 19 | * @method Asset Asset(integer $id = null) 20 | * 21 | */ 22 | class Theme extends ShopifyResource 23 | { 24 | /** 25 | * @inheritDoc 26 | */ 27 | public $resourceKey = 'theme'; 28 | 29 | /** 30 | * @inheritDoc 31 | */ 32 | public $countEnabled = false; 33 | 34 | /** 35 | * @inheritDoc 36 | */ 37 | protected $childResource = array( 38 | 'Asset' 39 | ); 40 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Transaction.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:27 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/transaction Shopify API Reference for Transaction 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Transaction extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'transaction'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Transactions.php: -------------------------------------------------------------------------------- 1 | 5 | * @author Matthew Crigger 6 | * 7 | * @see https://help.shopify.com/en/api/reference/shopify_payments/transaction Shopify API Reference for Shopify Payment Transactions 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Transactions extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'transaction'; 19 | 20 | /** 21 | * If the resource is read only. (No POST / PUT / DELETE actions) 22 | * 23 | * @var boolean 24 | */ 25 | public $readOnly = true; 26 | } 27 | -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/UsageCharge.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 7:49 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/usagecharge Shopify API Reference for UsageCharge 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class UsageCharge extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'usage_charge'; 19 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/User.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 8:00 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/user Shopify API Reference for User 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | /** 14 | * -------------------------------------------------------------------------- 15 | * User -> Custom actions 16 | * -------------------------------------------------------------------------- 17 | * @method array current() Get the current logged-in user 18 | * 19 | */ 20 | class User extends ShopifyResource 21 | { 22 | /** 23 | * @inheritDoc 24 | */ 25 | protected $resourceKey = 'user'; 26 | 27 | /** 28 | * @inheritDoc 29 | */ 30 | public $readOnly = true; 31 | 32 | /** 33 | * @inheritDoc 34 | */ 35 | protected $customGetActions = array ( 36 | 'current' 37 | ); 38 | } -------------------------------------------------------------------------------- /vendor/phpclassic/php-shopify/lib/Webhook.php: -------------------------------------------------------------------------------- 1 | 5 | * Created at 8/19/16 8:07 PM UTC+06:00 6 | * 7 | * @see https://help.shopify.com/api/reference/webhook Shopify API Reference for Webhook 8 | */ 9 | 10 | namespace PHPShopify; 11 | 12 | 13 | class Webhook extends ShopifyResource 14 | { 15 | /** 16 | * @inheritDoc 17 | */ 18 | protected $resourceKey = 'webhook'; 19 | } -------------------------------------------------------------------------------- /vendor/symfony/polyfill-ctype/Ctype.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | namespace Symfony\Polyfill\Ctype; 13 | 14 | /** 15 | * Ctype implementation through regex. 16 | * 17 | * @internal 18 | * 19 | * @author Gert de Pagter 20 | */ 21 | final class Ctype 22 | { 23 | /** 24 | * Returns TRUE if every character in text is either a letter or a digit, FALSE otherwise. 25 | * 26 | * @see https://php.net/ctype-alnum 27 | * 28 | * @param string|int $text 29 | * 30 | * @return bool 31 | */ 32 | public static function ctype_alnum($text) 33 | { 34 | $text = self::convert_int_to_char_for_ctype($text); 35 | 36 | return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z0-9]/', $text); 37 | } 38 | 39 | /** 40 | * Returns TRUE if every character in text is a letter, FALSE otherwise. 41 | * 42 | * @see https://php.net/ctype-alpha 43 | * 44 | * @param string|int $text 45 | * 46 | * @return bool 47 | */ 48 | public static function ctype_alpha($text) 49 | { 50 | $text = self::convert_int_to_char_for_ctype($text); 51 | 52 | return \is_string($text) && '' !== $text && !preg_match('/[^A-Za-z]/', $text); 53 | } 54 | 55 | /** 56 | * Returns TRUE if every character in text is a control character from the current locale, FALSE otherwise. 57 | * 58 | * @see https://php.net/ctype-cntrl 59 | * 60 | * @param string|int $text 61 | * 62 | * @return bool 63 | */ 64 | public static function ctype_cntrl($text) 65 | { 66 | $text = self::convert_int_to_char_for_ctype($text); 67 | 68 | return \is_string($text) && '' !== $text && !preg_match('/[^\x00-\x1f\x7f]/', $text); 69 | } 70 | 71 | /** 72 | * Returns TRUE if every character in the string text is a decimal digit, FALSE otherwise. 73 | * 74 | * @see https://php.net/ctype-digit 75 | * 76 | * @param string|int $text 77 | * 78 | * @return bool 79 | */ 80 | public static function ctype_digit($text) 81 | { 82 | $text = self::convert_int_to_char_for_ctype($text); 83 | 84 | return \is_string($text) && '' !== $text && !preg_match('/[^0-9]/', $text); 85 | } 86 | 87 | /** 88 | * Returns TRUE if every character in text is printable and actually creates visible output (no white space), FALSE otherwise. 89 | * 90 | * @see https://php.net/ctype-graph 91 | * 92 | * @param string|int $text 93 | * 94 | * @return bool 95 | */ 96 | public static function ctype_graph($text) 97 | { 98 | $text = self::convert_int_to_char_for_ctype($text); 99 | 100 | return \is_string($text) && '' !== $text && !preg_match('/[^!-~]/', $text); 101 | } 102 | 103 | /** 104 | * Returns TRUE if every character in text is a lowercase letter. 105 | * 106 | * @see https://php.net/ctype-lower 107 | * 108 | * @param string|int $text 109 | * 110 | * @return bool 111 | */ 112 | public static function ctype_lower($text) 113 | { 114 | $text = self::convert_int_to_char_for_ctype($text); 115 | 116 | return \is_string($text) && '' !== $text && !preg_match('/[^a-z]/', $text); 117 | } 118 | 119 | /** 120 | * Returns TRUE if every character in text will actually create output (including blanks). Returns FALSE if text contains control characters or characters that do not have any output or control function at all. 121 | * 122 | * @see https://php.net/ctype-print 123 | * 124 | * @param string|int $text 125 | * 126 | * @return bool 127 | */ 128 | public static function ctype_print($text) 129 | { 130 | $text = self::convert_int_to_char_for_ctype($text); 131 | 132 | return \is_string($text) && '' !== $text && !preg_match('/[^ -~]/', $text); 133 | } 134 | 135 | /** 136 | * Returns TRUE if every character in text is printable, but neither letter, digit or blank, FALSE otherwise. 137 | * 138 | * @see https://php.net/ctype-punct 139 | * 140 | * @param string|int $text 141 | * 142 | * @return bool 143 | */ 144 | public static function ctype_punct($text) 145 | { 146 | $text = self::convert_int_to_char_for_ctype($text); 147 | 148 | return \is_string($text) && '' !== $text && !preg_match('/[^!-\/\:-@\[-`\{-~]/', $text); 149 | } 150 | 151 | /** 152 | * Returns TRUE if every character in text creates some sort of white space, FALSE otherwise. Besides the blank character this also includes tab, vertical tab, line feed, carriage return and form feed characters. 153 | * 154 | * @see https://php.net/ctype-space 155 | * 156 | * @param string|int $text 157 | * 158 | * @return bool 159 | */ 160 | public static function ctype_space($text) 161 | { 162 | $text = self::convert_int_to_char_for_ctype($text); 163 | 164 | return \is_string($text) && '' !== $text && !preg_match('/[^\s]/', $text); 165 | } 166 | 167 | /** 168 | * Returns TRUE if every character in text is an uppercase letter. 169 | * 170 | * @see https://php.net/ctype-upper 171 | * 172 | * @param string|int $text 173 | * 174 | * @return bool 175 | */ 176 | public static function ctype_upper($text) 177 | { 178 | $text = self::convert_int_to_char_for_ctype($text); 179 | 180 | return \is_string($text) && '' !== $text && !preg_match('/[^A-Z]/', $text); 181 | } 182 | 183 | /** 184 | * Returns TRUE if every character in text is a hexadecimal 'digit', that is a decimal digit or a character from [A-Fa-f] , FALSE otherwise. 185 | * 186 | * @see https://php.net/ctype-xdigit 187 | * 188 | * @param string|int $text 189 | * 190 | * @return bool 191 | */ 192 | public static function ctype_xdigit($text) 193 | { 194 | $text = self::convert_int_to_char_for_ctype($text); 195 | 196 | return \is_string($text) && '' !== $text && !preg_match('/[^A-Fa-f0-9]/', $text); 197 | } 198 | 199 | /** 200 | * Converts integers to their char versions according to normal ctype behaviour, if needed. 201 | * 202 | * If an integer between -128 and 255 inclusive is provided, 203 | * it is interpreted as the ASCII value of a single character 204 | * (negative values have 256 added in order to allow characters in the Extended ASCII range). 205 | * Any other integer is interpreted as a string containing the decimal digits of the integer. 206 | * 207 | * @param string|int $int 208 | * 209 | * @return mixed 210 | */ 211 | private static function convert_int_to_char_for_ctype($int) 212 | { 213 | if (!\is_int($int)) { 214 | return $int; 215 | } 216 | 217 | if ($int < -128 || $int > 255) { 218 | return (string) $int; 219 | } 220 | 221 | if ($int < 0) { 222 | $int += 256; 223 | } 224 | 225 | return \chr($int); 226 | } 227 | } 228 | -------------------------------------------------------------------------------- /vendor/symfony/polyfill-ctype/bootstrap.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Symfony\Polyfill\Ctype as p; 13 | 14 | if (\PHP_VERSION_ID >= 80000) { 15 | return require __DIR__.'/bootstrap80.php'; 16 | } 17 | 18 | if (!function_exists('ctype_alnum')) { 19 | function ctype_alnum($text) { return p\Ctype::ctype_alnum($text); } 20 | } 21 | if (!function_exists('ctype_alpha')) { 22 | function ctype_alpha($text) { return p\Ctype::ctype_alpha($text); } 23 | } 24 | if (!function_exists('ctype_cntrl')) { 25 | function ctype_cntrl($text) { return p\Ctype::ctype_cntrl($text); } 26 | } 27 | if (!function_exists('ctype_digit')) { 28 | function ctype_digit($text) { return p\Ctype::ctype_digit($text); } 29 | } 30 | if (!function_exists('ctype_graph')) { 31 | function ctype_graph($text) { return p\Ctype::ctype_graph($text); } 32 | } 33 | if (!function_exists('ctype_lower')) { 34 | function ctype_lower($text) { return p\Ctype::ctype_lower($text); } 35 | } 36 | if (!function_exists('ctype_print')) { 37 | function ctype_print($text) { return p\Ctype::ctype_print($text); } 38 | } 39 | if (!function_exists('ctype_punct')) { 40 | function ctype_punct($text) { return p\Ctype::ctype_punct($text); } 41 | } 42 | if (!function_exists('ctype_space')) { 43 | function ctype_space($text) { return p\Ctype::ctype_space($text); } 44 | } 45 | if (!function_exists('ctype_upper')) { 46 | function ctype_upper($text) { return p\Ctype::ctype_upper($text); } 47 | } 48 | if (!function_exists('ctype_xdigit')) { 49 | function ctype_xdigit($text) { return p\Ctype::ctype_xdigit($text); } 50 | } 51 | -------------------------------------------------------------------------------- /vendor/symfony/polyfill-ctype/bootstrap80.php: -------------------------------------------------------------------------------- 1 | 7 | * 8 | * For the full copyright and license information, please view the LICENSE 9 | * file that was distributed with this source code. 10 | */ 11 | 12 | use Symfony\Polyfill\Ctype as p; 13 | 14 | if (!function_exists('ctype_alnum')) { 15 | function ctype_alnum(mixed $text): bool { return p\Ctype::ctype_alnum($text); } 16 | } 17 | if (!function_exists('ctype_alpha')) { 18 | function ctype_alpha(mixed $text): bool { return p\Ctype::ctype_alpha($text); } 19 | } 20 | if (!function_exists('ctype_cntrl')) { 21 | function ctype_cntrl(mixed $text): bool { return p\Ctype::ctype_cntrl($text); } 22 | } 23 | if (!function_exists('ctype_digit')) { 24 | function ctype_digit(mixed $text): bool { return p\Ctype::ctype_digit($text); } 25 | } 26 | if (!function_exists('ctype_graph')) { 27 | function ctype_graph(mixed $text): bool { return p\Ctype::ctype_graph($text); } 28 | } 29 | if (!function_exists('ctype_lower')) { 30 | function ctype_lower(mixed $text): bool { return p\Ctype::ctype_lower($text); } 31 | } 32 | if (!function_exists('ctype_print')) { 33 | function ctype_print(mixed $text): bool { return p\Ctype::ctype_print($text); } 34 | } 35 | if (!function_exists('ctype_punct')) { 36 | function ctype_punct(mixed $text): bool { return p\Ctype::ctype_punct($text); } 37 | } 38 | if (!function_exists('ctype_space')) { 39 | function ctype_space(mixed $text): bool { return p\Ctype::ctype_space($text); } 40 | } 41 | if (!function_exists('ctype_upper')) { 42 | function ctype_upper(mixed $text): bool { return p\Ctype::ctype_upper($text); } 43 | } 44 | if (!function_exists('ctype_xdigit')) { 45 | function ctype_xdigit(mixed $text): bool { return p\Ctype::ctype_xdigit($text); } 46 | } 47 | -------------------------------------------------------------------------------- /vendor/vlucas/phpdotenv/src/Dotenv.php: -------------------------------------------------------------------------------- 1 | filePath = $this->getFilePath($path, $file); 40 | $this->loader = new Loader($this->filePath, true); 41 | } 42 | 43 | /** 44 | * Load environment file in given directory. 45 | * 46 | * @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException 47 | * 48 | * @return array 49 | */ 50 | public function load() 51 | { 52 | return $this->loadData(); 53 | } 54 | 55 | /** 56 | * Load environment file in given directory, suppress InvalidPathException. 57 | * 58 | * @throws \Dotenv\Exception\InvalidFileException 59 | * 60 | * @return array 61 | */ 62 | public function safeLoad() 63 | { 64 | try { 65 | return $this->loadData(); 66 | } catch (InvalidPathException $e) { 67 | // suppressing exception 68 | return array(); 69 | } 70 | } 71 | 72 | /** 73 | * Load environment file in given directory. 74 | * 75 | * @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException 76 | * 77 | * @return array 78 | */ 79 | public function overload() 80 | { 81 | return $this->loadData(true); 82 | } 83 | 84 | /** 85 | * Returns the full path to the file. 86 | * 87 | * @param string $path 88 | * @param string $file 89 | * 90 | * @return string 91 | */ 92 | protected function getFilePath($path, $file) 93 | { 94 | if (!is_string($file)) { 95 | $file = '.env'; 96 | } 97 | 98 | $filePath = rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.$file; 99 | 100 | return $filePath; 101 | } 102 | 103 | /** 104 | * Actually load the data. 105 | * 106 | * @param bool $overload 107 | * 108 | * @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException 109 | * 110 | * @return array 111 | */ 112 | protected function loadData($overload = false) 113 | { 114 | return $this->loader->setImmutable(!$overload)->load(); 115 | } 116 | 117 | /** 118 | * Required ensures that the specified variables exist, and returns a new validator object. 119 | * 120 | * @param string|string[] $variable 121 | * 122 | * @return \Dotenv\Validator 123 | */ 124 | public function required($variable) 125 | { 126 | return new Validator((array) $variable, $this->loader); 127 | } 128 | 129 | /** 130 | * Get the list of environment variables declared inside the 'env' file. 131 | * 132 | * @return array 133 | */ 134 | public function getEnvironmentVariableNames() 135 | { 136 | return $this->loader->variableNames; 137 | } 138 | } 139 | -------------------------------------------------------------------------------- /vendor/vlucas/phpdotenv/src/Exception/ExceptionInterface.php: -------------------------------------------------------------------------------- 1 | filePath = $filePath; 48 | $this->immutable = $immutable; 49 | } 50 | 51 | /** 52 | * Set immutable value. 53 | * 54 | * @param bool $immutable 55 | * 56 | * @return $this 57 | */ 58 | public function setImmutable($immutable = false) 59 | { 60 | $this->immutable = $immutable; 61 | 62 | return $this; 63 | } 64 | 65 | /** 66 | * Get immutable value. 67 | * 68 | * @return bool 69 | */ 70 | public function getImmutable() 71 | { 72 | return $this->immutable; 73 | } 74 | 75 | /** 76 | * Load `.env` file in given directory. 77 | * 78 | * @throws \Dotenv\Exception\InvalidPathException|\Dotenv\Exception\InvalidFileException 79 | * 80 | * @return array 81 | */ 82 | public function load() 83 | { 84 | $this->ensureFileIsReadable(); 85 | 86 | $filePath = $this->filePath; 87 | $lines = $this->readLinesFromFile($filePath); 88 | foreach ($lines as $line) { 89 | if (!$this->isComment($line) && $this->looksLikeSetter($line)) { 90 | $this->setEnvironmentVariable($line); 91 | } 92 | } 93 | 94 | return $lines; 95 | } 96 | 97 | /** 98 | * Ensures the given filePath is readable. 99 | * 100 | * @throws \Dotenv\Exception\InvalidPathException 101 | * 102 | * @return void 103 | */ 104 | protected function ensureFileIsReadable() 105 | { 106 | if (!is_readable($this->filePath) || !is_file($this->filePath)) { 107 | throw new InvalidPathException(sprintf('Unable to read the environment file at %s.', $this->filePath)); 108 | } 109 | } 110 | 111 | /** 112 | * Normalise the given environment variable. 113 | * 114 | * Takes value as passed in by developer and: 115 | * - ensures we're dealing with a separate name and value, breaking apart the name string if needed, 116 | * - cleaning the value of quotes, 117 | * - cleaning the name of quotes, 118 | * - resolving nested variables. 119 | * 120 | * @param string $name 121 | * @param string $value 122 | * 123 | * @throws \Dotenv\Exception\InvalidFileException 124 | * 125 | * @return array 126 | */ 127 | protected function normaliseEnvironmentVariable($name, $value) 128 | { 129 | list($name, $value) = $this->processFilters($name, $value); 130 | 131 | $value = $this->resolveNestedVariables($value); 132 | 133 | return array($name, $value); 134 | } 135 | 136 | /** 137 | * Process the runtime filters. 138 | * 139 | * Called from `normaliseEnvironmentVariable` and the `VariableFactory`, passed as a callback in `$this->loadFromFile()`. 140 | * 141 | * @param string $name 142 | * @param string $value 143 | * 144 | * @throws \Dotenv\Exception\InvalidFileException 145 | * 146 | * @return array 147 | */ 148 | public function processFilters($name, $value) 149 | { 150 | list($name, $value) = $this->splitCompoundStringIntoParts($name, $value); 151 | list($name, $value) = $this->sanitiseVariableName($name, $value); 152 | list($name, $value) = $this->sanitiseVariableValue($name, $value); 153 | 154 | return array($name, $value); 155 | } 156 | 157 | /** 158 | * Read lines from the file, auto detecting line endings. 159 | * 160 | * @param string $filePath 161 | * 162 | * @return array 163 | */ 164 | protected function readLinesFromFile($filePath) 165 | { 166 | // Read file into an array of lines with auto-detected line endings 167 | $autodetect = ini_get('auto_detect_line_endings'); 168 | ini_set('auto_detect_line_endings', '1'); 169 | $lines = file($filePath, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); 170 | ini_set('auto_detect_line_endings', $autodetect); 171 | 172 | return $lines; 173 | } 174 | 175 | /** 176 | * Determine if the line in the file is a comment, e.g. begins with a #. 177 | * 178 | * @param string $line 179 | * 180 | * @return bool 181 | */ 182 | protected function isComment($line) 183 | { 184 | $line = ltrim($line); 185 | 186 | return isset($line[0]) && $line[0] === '#'; 187 | } 188 | 189 | /** 190 | * Determine if the given line looks like it's setting a variable. 191 | * 192 | * @param string $line 193 | * 194 | * @return bool 195 | */ 196 | protected function looksLikeSetter($line) 197 | { 198 | return strpos($line, '=') !== false; 199 | } 200 | 201 | /** 202 | * Split the compound string into parts. 203 | * 204 | * If the `$name` contains an `=` sign, then we split it into 2 parts, a `name` & `value` 205 | * disregarding the `$value` passed in. 206 | * 207 | * @param string $name 208 | * @param string $value 209 | * 210 | * @return array 211 | */ 212 | protected function splitCompoundStringIntoParts($name, $value) 213 | { 214 | if (strpos($name, '=') !== false) { 215 | list($name, $value) = array_map('trim', explode('=', $name, 2)); 216 | } 217 | 218 | return array($name, $value); 219 | } 220 | 221 | /** 222 | * Strips quotes from the environment variable value. 223 | * 224 | * @param string $name 225 | * @param string $value 226 | * 227 | * @throws \Dotenv\Exception\InvalidFileException 228 | * 229 | * @return array 230 | */ 231 | protected function sanitiseVariableValue($name, $value) 232 | { 233 | $value = trim($value); 234 | if (!$value) { 235 | return array($name, $value); 236 | } 237 | 238 | return array($name, Parser::parseValue($value)); 239 | } 240 | 241 | /** 242 | * Resolve the nested variables. 243 | * 244 | * Look for ${varname} patterns in the variable value and replace with an 245 | * existing environment variable. 246 | * 247 | * @param string $value 248 | * 249 | * @return mixed 250 | */ 251 | protected function resolveNestedVariables($value) 252 | { 253 | if (strpos($value, '$') !== false) { 254 | $loader = $this; 255 | $value = preg_replace_callback( 256 | '/\${([a-zA-Z0-9_.]+)}/', 257 | function ($matchedPatterns) use ($loader) { 258 | $nestedVariable = $loader->getEnvironmentVariable($matchedPatterns[1]); 259 | if ($nestedVariable === null) { 260 | return $matchedPatterns[0]; 261 | } else { 262 | return $nestedVariable; 263 | } 264 | }, 265 | $value 266 | ); 267 | } 268 | 269 | return $value; 270 | } 271 | 272 | /** 273 | * Strips quotes and the optional leading "export " from the environment variable name. 274 | * 275 | * @param string $name 276 | * @param string $value 277 | * 278 | * @return array 279 | */ 280 | protected function sanitiseVariableName($name, $value) 281 | { 282 | return array(Parser::parseName($name), $value); 283 | } 284 | 285 | /** 286 | * Search the different places for environment variables and return first value found. 287 | * 288 | * @param string $name 289 | * 290 | * @return string|null 291 | */ 292 | public function getEnvironmentVariable($name) 293 | { 294 | switch (true) { 295 | case array_key_exists($name, $_ENV): 296 | return $_ENV[$name]; 297 | case array_key_exists($name, $_SERVER): 298 | return $_SERVER[$name]; 299 | default: 300 | $value = getenv($name); 301 | 302 | return $value === false ? null : $value; // switch getenv default to null 303 | } 304 | } 305 | 306 | /** 307 | * Set an environment variable. 308 | * 309 | * This is done using: 310 | * - putenv, 311 | * - $_ENV, 312 | * - $_SERVER. 313 | * 314 | * The environment variable value is stripped of single and double quotes. 315 | * 316 | * @param string $name 317 | * @param string|null $value 318 | * 319 | * @throws \Dotenv\Exception\InvalidFileException 320 | * 321 | * @return void 322 | */ 323 | public function setEnvironmentVariable($name, $value = null) 324 | { 325 | list($name, $value) = $this->normaliseEnvironmentVariable($name, $value); 326 | 327 | $this->variableNames[] = $name; 328 | 329 | // Don't overwrite existing environment variables if we're immutable 330 | // Ruby's dotenv does this with `ENV[key] ||= value`. 331 | if ($this->immutable && $this->getEnvironmentVariable($name) !== null) { 332 | return; 333 | } 334 | 335 | // If PHP is running as an Apache module and an existing 336 | // Apache environment variable exists, overwrite it 337 | if (function_exists('apache_getenv') && function_exists('apache_setenv') && apache_getenv($name) !== false) { 338 | apache_setenv($name, $value); 339 | } 340 | 341 | if (function_exists('putenv')) { 342 | putenv("$name=$value"); 343 | } 344 | 345 | $_ENV[$name] = $value; 346 | $_SERVER[$name] = $value; 347 | } 348 | 349 | /** 350 | * Clear an environment variable. 351 | * 352 | * This is not (currently) used by Dotenv but is provided as a utility 353 | * method for 3rd party code. 354 | * 355 | * This is done using: 356 | * - putenv, 357 | * - unset($_ENV, $_SERVER). 358 | * 359 | * @param string $name 360 | * 361 | * @see setEnvironmentVariable() 362 | * 363 | * @return void 364 | */ 365 | public function clearEnvironmentVariable($name) 366 | { 367 | // Don't clear anything if we're immutable. 368 | if ($this->immutable) { 369 | return; 370 | } 371 | 372 | if (function_exists('putenv')) { 373 | putenv($name); 374 | } 375 | 376 | unset($_ENV[$name], $_SERVER[$name]); 377 | } 378 | } 379 | -------------------------------------------------------------------------------- /vendor/vlucas/phpdotenv/src/Parser.php: -------------------------------------------------------------------------------- 1 | 0) { 116 | // Check if value is a comment (usually triggered when empty value with comment) 117 | if (preg_match('/^#/', $value) > 0) { 118 | $value = ''; 119 | } else { 120 | throw new InvalidFileException('Dotenv values containing spaces must be surrounded by quotes.'); 121 | } 122 | } 123 | 124 | return trim($value); 125 | } 126 | } 127 | -------------------------------------------------------------------------------- /vendor/vlucas/phpdotenv/src/Validator.php: -------------------------------------------------------------------------------- 1 | variables = $variables; 40 | $this->loader = $loader; 41 | 42 | $this->assertCallback( 43 | function ($value) { 44 | return $value !== null; 45 | }, 46 | 'is missing' 47 | ); 48 | } 49 | 50 | /** 51 | * Assert that each variable is not empty. 52 | * 53 | * @return \Dotenv\Validator 54 | */ 55 | public function notEmpty() 56 | { 57 | return $this->assertCallback( 58 | function ($value) { 59 | return strlen(trim($value)) > 0; 60 | }, 61 | 'is empty' 62 | ); 63 | } 64 | 65 | /** 66 | * Assert that each specified variable is an integer. 67 | * 68 | * @return \Dotenv\Validator 69 | */ 70 | public function isInteger() 71 | { 72 | return $this->assertCallback( 73 | function ($value) { 74 | return ctype_digit($value); 75 | }, 76 | 'is not an integer' 77 | ); 78 | } 79 | 80 | /** 81 | * Assert that each specified variable is a boolean. 82 | * 83 | * @return \Dotenv\Validator 84 | */ 85 | public function isBoolean() 86 | { 87 | return $this->assertCallback( 88 | function ($value) { 89 | if ($value === '') { 90 | return false; 91 | } 92 | 93 | return filter_var($value, FILTER_VALIDATE_BOOLEAN, FILTER_NULL_ON_FAILURE) !== null; 94 | }, 95 | 'is not a boolean' 96 | ); 97 | } 98 | 99 | /** 100 | * Assert that each variable is amongst the given choices. 101 | * 102 | * @param string[] $choices 103 | * 104 | * @return \Dotenv\Validator 105 | */ 106 | public function allowedValues(array $choices) 107 | { 108 | return $this->assertCallback( 109 | function ($value) use ($choices) { 110 | return in_array($value, $choices); 111 | }, 112 | 'is not an allowed value' 113 | ); 114 | } 115 | 116 | /** 117 | * Assert that the callback returns true for each variable. 118 | * 119 | * @param callable $callback 120 | * @param string $message 121 | * 122 | * @throws \Dotenv\Exception\InvalidCallbackException|\Dotenv\Exception\ValidationException 123 | * 124 | * @return \Dotenv\Validator 125 | */ 126 | protected function assertCallback($callback, $message = 'failed callback assertion') 127 | { 128 | if (!is_callable($callback)) { 129 | throw new InvalidCallbackException('The provided callback must be callable.'); 130 | } 131 | 132 | $variablesFailingAssertion = array(); 133 | foreach ($this->variables as $variableName) { 134 | $variableValue = $this->loader->getEnvironmentVariable($variableName); 135 | if (call_user_func($callback, $variableValue) === false) { 136 | $variablesFailingAssertion[] = $variableName." $message"; 137 | } 138 | } 139 | 140 | if (count($variablesFailingAssertion) > 0) { 141 | throw new ValidationException(sprintf( 142 | 'One or more environment variables failed assertions: %s.', 143 | implode(', ', $variablesFailingAssertion) 144 | )); 145 | } 146 | 147 | return $this; 148 | } 149 | } 150 | --------------------------------------------------------------------------------