Shopify API Client
, (*1)
This package provides a client to communicate with the Shopify api., (*2)
Install
Via Composer, (*3)
``` bash
$ composer require edwin-luijten/shopify-client, (*4)
## Usage
### Creating a Shopify application
Read the following documentation: https://help.shopify.com/api/getting-started
### Using the Client
``` php
$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:, (*5)
``` php
$totalProducts = $client->products->count();
$perPage = 50;
$pages = $totalProducts <= 50 ? 1: round($totalProducts / $perPage);, (*6)
for($i = 0; $i <= $pages; $i++) {
$products = \ShopifyClient\Request::throttle(function($client, $i) {
return $client->products->all([
'page' => $i,
]);
});
}, (*7)
### Add your own resources
Check https://github.com/Edwin-Luijten/shopify-client/tree/develop/src/Resource for how to create your own resource.
``` php
$config = new \ShopifyClient\Config($domain, $key, $secret, [
'helloWorld' => \HelloWorldClass::class,
];
$client = new \ShopifyClient\Client($config);
Implemented resources
- [x] Abandoned checkouts
- [x] Article (Accessible trough blogs)
- [x] Blog
- [ ] CarrierService
- [ ] Checkout
- [ ] Collect
- [ ] CollectionListing
- [ ] Comment
- [x] Country
- [ ] CustomCollection
- [x] Customer
- [x] CustomerAddress (Accessible trough customers)
- [ ] CustomerSavedSearch
- [x] DiscountCode (Accessible trough priceRules)
- [ ] DraftOrder
- [ ] Event
- [x] Fulfillment
- [x] FulfillmentEvent
- [x] FulfillmentService
- [ ] Gift Card (Shopify Plus)
- [ ] Location
- [ ] Marketing Event
- [x] Metafield (products, variants, orders, blogs, articles)
- [ ] Multipass (Shopify Plus)
- [x] Order
- [x] Order Risks (Accessible trough orders)
- [ ] Page
- [ ] Policy
- [x] PriceRule
- [x] Product
- [x] Product Image (Accessible trough products)
- [x] Product Variant (Accessible trough products)
- [ ] ProductListing
- [x] Province (Accessible trough countries)
- [ ] RecurringApplicationCharge
- [ ] Redirect
- [ ] Refund
- [ ] Report
- [ ] ResourceFeedback
- [ ] ScriptTag
- [ ] Shipping Zone
- [x] Shop
- [ ] SmartCollection
- [ ] Storefront Access Token
- [ ] Theme
- [ ] Transaction
- [ ] UsageCharge
- [x] User (Shopify Plus)
- [x] Webhook
- [ ] ShopifyQL
Testing
Set some environment variables first:
- SHOPIFY_DOMAIN
- SHOPIFY_KEY
- SHOPIFY_SECRET
- SHOPIFY_RATE_LIMIT
- SHOPIFY_PRODUCT_VARIANT_ID, (*8)
bash
$ ./vendor/bin/phpunit
, (*9)
Contributing
Please see CONTRIBUTING for details., (*10)
Security
If you discover any security related issues, please email :author_email instead of using the issue tracker., (*11)
Credits
License
The MIT License (MIT). Please see License File for more information., (*12)