bold-commerce / bold-shopify-toolkit
6.1.0-beta
2024-06-21 17:15 UTC
Requires
- guzzlehttp/guzzle: ^6.2 || ^7.1
- illuminate/support: 5.2.* || 5.3.* || 5.4.* || 5.5.* || 5.6.* || 5.7.* || 5.8.* || ^6 || ^7 || ^8 || ^9
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.11.0
- phpunit/phpunit: ^9.5.24
- dev-master
- 6.1.0-beta
- 6.0.0
- 5.6.1
- 5.6.0
- 5.5.4
- 5.5.3
- 5.5.2
- 5.5.1
- 5.5.0
- 5.4.3
- 5.4.2
- 5.4.1
- 5.4.0
- 5.3.0
- 5.2.0
- 5.1.0
- v5.0.0
- 4.x-dev
- 4.1.1
- 4.1.0
- 4.0.3-beta
- 4.0.2
- 4.0.2-beta
- 4.0.1
- v4.0.0
- 3.4.0
- 3.3.0
- 3.2.0
- 3.1.0
- 3.0.0
- 2.13.3
- 2.13.2
- 2.13.1
- 2.13.0
- 2.12.0
- 2.11.0
- 2.10.0
- 2.9.0
- 2.8.1
- 2.8.0
- 2.7.0
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.2
- 2.4.1
- 2.4.0
- 2.3.0
- 2.2.7
- 2.2.6
- 2.2.5
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.2
- 2.1.1
- 2.1.0
- 2.0.2
- 2.0.1
- 2.0.0
- 1.10.1
- 1.10.0
- 1.9.2
- 1.9.1
- 1.9.0
- 1.8.4
- 1.8.3
- 1.8.2
- 1.8.1
- 1.8.0
- 1.7.2
- 1.7.1
- 1.7.0
- 1.6.6
- 1.6.5
- 1.6.4
- 1.6.3
- 1.6.2
- 1.6.1
- 1.6.0
- 1.5.5
- 1.5.4
- 1.5.3
- 1.5.2
- 1.5.1
- 1.5.0
- 1.4.12
- 1.4.11
- 1.4.10
- 1.4.9
- 1.4.8
- 1.4.7
- 1.4.6
- 1.4.5
- 1.4.4
- 1.4.3
- 1.4.2
- 1.4.1
- 1.4.0
- 1.3.5
- 1.3.4
- 1.3.3
- 1.3.2
- 1.3.1
- 1.3.0
- 1.2.24
- 1.2.23
- 1.2.22
- 1.2.21
- 1.2.20
- 1.2.19
- 1.2.18
- 1.2.17
- 1.2.16
- 1.2.15
- 1.2.14
- 1.2.13
- 1.2.12
- 1.2.11
- 1.2.10
- 1.2.9
- 1.2.8
- 1.2.7
- 1.2.6
- 1.2.5
- 1.2.4
- 1.2.3
- 1.2.2
- 1.2.1
- 1.2.0
- 1.1.0
- 1.0.1
- 1.0.0
- dev-SHOP-3316-SO-Batch-Improvements
- dev-SHOP-2754
- dev-revert-fulfillment-service-removal
- dev-SHOP-2538
- dev-Location-header-fix
- dev-add-graphql-request
- dev-use_api_version_for_theme
- dev-api-update-2023-01
- dev-php-7
- dev-shopify-api-2022-07
- dev-update-exception-from-shopify
- dev-new-test
This package is auto-updated.
Last update: 2024-09-20 15:06:45 UTC
README
目的
Bold Shopify Toolkit 是一个基于 Symfony 和 Shopify 的包装器,可以轻松地与 Shopify 进行交互。目的是集成 Shopify 提供的 API,并为访问这些端点的模型和服务保持一致的数据结构。
入门
此包与依赖注入容器配合使用最佳,因为需要解决许多依赖项。
先决条件
使用此包,您需要将以下接口绑定到模型。
本包已包含一个示例 API Sleeper。
Laravel: (见 AppServiceProvider.php
)
$this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class, \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class);
安装
添加到 composer.json
$ composer require bold-commerce/bold-shopify-toolkit
在请求生命周期中绑定适当的模型。
$this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class, \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class); ...
对于使用容器系统的应用程序,此操作如下所示
$shopifyApiHandler = new ShopifyApiHandler(); $this->getContainer()->addShared(RequestHookInterface::class, $shopifyApiHandler); $this->getContainer()->addShared(ApiSleeper::class, $shopifyApiHandler);
上述代码可以是服务提供器类的一部分
在调用工具包的服务和/或模型之前,绑定将使用工具包的商店。
// $shop - Eloquent model containing at least the myshopify_domain ("example.myshopify.com") app()->instance(BoldApps\ShopifyToolkit\Contracts\ShopBaseInfo::class, $shop); // $accessToken - Contains the access token string created when the shop installed the app app()->instance(BoldApps\ShopifyToolkit\Contracts\ShopAccessInfo::class, $accessToken);
运行测试
$ vendor/bin/phpunit tests
提供了一个 Dockerfile,用于以与 Circle 相同的方式运行测试
$ ./runtests.sh
示例
创建代表您想要使用的 API 的服务
$variantService = new BoldApps\ShopifyToolkit\Services\Variant(); //OR $variantService = app()->make(BoldApps\ShopifyToolkit\Services\Variant::class);
获取单个变体模型
/** @var BoldApps\ShopifyToolkit\Models\Variant $variant */ $variant = $variantService->getById(2641814487051); $variant->getPrice(); //99.0
获取变体模型集合并使用产品 ID 过滤,以仅获取它们的标题
/** @var Illuminate\Support\Collection $variants */ $variants = $variantService->getAllByProductId(327661486091, ["fields" => "title"]); /** @var BoldApps\ShopifyToolkit\Models\Variant $variant */ foreach ($variants as $variant) { $title = $variant->getTitle(); //"Default title" }
更新变体
$variant->setOption1("Not pink"); $updatedVariant = $variantService->update($variant); $updatedVariant->getOption1(); //"Not pink"
查看 tests/VariantTest.php
以了解如何序列化和反序列化模型的一个示例。
待办事项
- 添加更多测试
- 添加 ShopifyApiHandler 的高级使用示例
贡献
欢迎拉取请求和想法!打开一个问题,我们来谈谈。
版本控制
我们使用 SemVer 进行版本控制。有关可用的版本,请参阅本存储库的 标签。
许可
本项目采用 Apache 2 许可证 - 详细信息请参阅 LICENSE.md 文件。
致谢
- 感谢 Shopify 为我们提供了最佳的开发者网络!
- 感谢 Bold Commerce 开发者为这个惊人的包所作的贡献。