edwin-luijten / shopify-client
与 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-09-22 09:03:14 UTC
README
此包提供了一个用于与 Shopify api 通信的客户端。
安装
通过 Composer
$ composer require edwin-luijten/shopify-client
使用方法
创建 Shopify 应用程序
阅读以下文档: https://help.shopify.com/api/getting-started
使用客户端
$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);
限制请求以防止桶溢出
$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, ]); }); }
添加自己的资源
查看 https://github.com/Edwin-Luijten/shopify-client/tree/develop/src/Resource 了解如何创建自己的资源。
$config = new \ShopifyClient\Config($domain, $key, $secret, [ 'helloWorld' => \HelloWorldClass::class, ]; $client = new \ShopifyClient\Client($config);
已实现的资源
- 被遗弃的结账
- 文章(通过博客访问)
- 博客
- 承运服务
- 结账
- 收藏夹
- 收藏夹列表
- 评论
- 国家
- 自定义收藏夹
- 客户
- 客户地址(通过客户访问)
- 客户保存的搜索
- 折扣代码(通过价格规则访问)
- 草稿订单
- 事件
- 履行
- 履行事件
- 履行服务
- 礼品卡(Shopify Plus)
- 位置
- 营销活动
- 元字段(产品、变体、订单、博客、文章)
- 多通行证(Shopify Plus)
- 订单
- 订单风险(通过订单访问)
- 页面
- 政策
- 价格规则
- 产品
- 产品图片(通过产品访问)
- 产品变体(通过产品访问)
- 产品列表
- 省(通过国家访问)
- 周期性应用程序收费
- 重定向
- 退款
- 报告
- 资源反馈
- 脚本标签
- 航运区
- 商店
- 智能收藏夹
- 商店前端访问令牌
- 主题
- 交易
- 使用费
- 用户(Shopify Plus)
- Webhook
- ShopifyQL
测试
首先设置一些环境变量
- SHOPIFY_DOMAIN
- SHOPIFY_KEY
- SHOPIFY_SECRET
- SHOPIFY_RATE_LIMIT
- SHOPIFY_PRODUCT_VARIANT_ID
$ ./vendor/bin/phpunit
贡献
请参阅 CONTRIBUTING 了解详细信息。
安全
如果您发现任何安全相关的问题,请通过 :author_email 发送电子邮件,而不是使用问题跟踪器。
鸣谢
许可证
MIT 许可证(MIT)。有关更多信息,请参阅 许可证文件。