edwin-luijten / shopify-client
A client to communicate to the Shopify api.
v0.0.2
2017-11-03 07:45 UTC
Requires
- php: >=7.0
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- phpunit/phpunit: ^6.3
- squizlabs/php_codesniffer: ^3.1
This package is not auto-updated.
Last update: 2024-11-03 09:28:59 UTC
README
This package provides a client to communicate with the Shopify api.
Install
Via Composer
$ composer require edwin-luijten/shopify-client
Usage
Creating a Shopify application
Read the following documentation: https://help.shopify.com/api/getting-started
Using the Client
$client = new \ShopifyClient\Client(new \ShopifyClient\Config($domain, $key, $secret)); $client->orders->get(1); $client->orders->all(); $client->orders->all([ 'page' => 2, ]); $client->orders->metafields->all($orderId);
Throttle request to prevent bucket overflow:
$totalProducts = $client->products->count(); $perPage = 50; $pages = $totalProducts <= 50 ? 1: round($totalProducts / $perPage); for($i = 0; $i <= $pages; $i++) { $products = \ShopifyClient\Request::throttle(function($client, $i) { return $client->products->all([ 'page' => $i, ]); }); }
Add your own resources
Check https://github.com/Edwin-Luijten/shopify-client/tree/develop/src/Resource for how to create your own resource.
$config = new \ShopifyClient\Config($domain, $key, $secret, [ 'helloWorld' => \HelloWorldClass::class, ]; $client = new \ShopifyClient\Client($config);
Implemented resources
- Abandoned checkouts
- Article (Accessible trough blogs)
- Blog
- CarrierService
- Checkout
- Collect
- CollectionListing
- Comment
- Country
- CustomCollection
- Customer
- CustomerAddress (Accessible trough customers)
- CustomerSavedSearch
- DiscountCode (Accessible trough priceRules)
- DraftOrder
- Event
- Fulfillment
- FulfillmentEvent
- FulfillmentService
- Gift Card (Shopify Plus)
- Location
- Marketing Event
- Metafield (products, variants, orders, blogs, articles)
- Multipass (Shopify Plus)
- Order
- Order Risks (Accessible trough orders)
- Page
- Policy
- PriceRule
- Product
- Product Image (Accessible trough products)
- Product Variant (Accessible trough products)
- ProductListing
- Province (Accessible trough countries)
- RecurringApplicationCharge
- Redirect
- Refund
- Report
- ResourceFeedback
- ScriptTag
- Shipping Zone
- Shop
- SmartCollection
- Storefront Access Token
- Theme
- Transaction
- UsageCharge
- User (Shopify Plus)
- Webhook
- ShopifyQL
Testing
Set some environment variables first:
- SHOPIFY_DOMAIN
- SHOPIFY_KEY
- SHOPIFY_SECRET
- SHOPIFY_RATE_LIMIT
- SHOPIFY_PRODUCT_VARIANT_ID
$ ./vendor/bin/phpunit
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.