bold-commerce/bold-shopify-toolkit
Composer 安装命令:
composer require bold-commerce/bold-shopify-toolkit
包简介
README 文档
README
Purpose
Bold Shopify Toolkit is a Symfony-based Shopify wrapper that makes it easy to interact with Shopify. The intention is to integrate with the API offered by Shopify and maintain consistent data structures for the models and services that access these endpoints.
Getting Started
This package works best with a Dependency Injection Container since there are many dependencies that need to be resolved.
Prerequisites
To use this package, you will need to bind Models to the following interfaces.
An example API Sleeper has been included in this package.
Laravel: (see AppServiceProvider.php)
$this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class, \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class);
Installing
Add to composer.json
$ composer require bold-commerce/bold-shopify-toolkit
Bind the appropriate models during your request lifecycle.
$this->app->bind(\BoldApps\ShopifyToolkit\Contracts\ApiSleeper::class, \BoldApps\ShopifyToolkit\Support\ShopifyApiHandler::class); ...
Or for apps that use container system this will look like below
$shopifyApiHandler = new ShopifyApiHandler(); $this->getContainer()->addShared(RequestHookInterface::class, $shopifyApiHandler); $this->getContainer()->addShared(ApiSleeper::class, $shopifyApiHandler);
above code can be part of a service provider class
Bind the shop that will be using the toolkit before making calls to its services and/or models.
// $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);
Running the tests
$ vendor/bin/phpunit tests
There is a dockerfile provided for running the tests the same way it will run on Circle
$ ./runtests.sh
Examples
Create the service representing the API you would like to use:
$variantService = new BoldApps\ShopifyToolkit\Services\Variant(); //OR $variantService = app()->make(BoldApps\ShopifyToolkit\Services\Variant::class);
Get a single variant model:
/** @var BoldApps\ShopifyToolkit\Models\Variant $variant */ $variant = $variantService->getById(2641814487051); $variant->getPrice(); //99.0
Get a collection of variant models and filter it so that we only get their titles, using the product 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" }
Update a variant:
$variant->setOption1("Not pink"); $updatedVariant = $variantService->update($variant); $updatedVariant->getOption1(); //"Not pink"
See tests/VariantTest.php for an example of how to serialize and deserialize a model.
TODO
- Add more tests
- Add example of advance usage of ShopifyApiHandler
Contributing
Pull requests and ideas are welcome! Open an issue and lets talk.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
License
This project is licensed under the Apache 2 License - see the LICENSE.md file for details
Acknowledgments
- Thanks to Shopify for making the best Developer Network!
- Thanks to Bold Commerce Developers for making this amazing package
bold-commerce/bold-shopify-toolkit 适用场景与选型建议
bold-commerce/bold-shopify-toolkit 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 101.02k 次下载、GitHub Stars 达 26, 最近一次更新时间为 2017 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 bold-commerce/bold-shopify-toolkit 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 bold-commerce/bold-shopify-toolkit 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 101.02k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 28
- 点击次数: 21
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2017-07-14