Skip to content
A Symfony Based Shopify api wrapper
Branch: master
Clone or download
jeremyw76 and rickywiens CI-605 Include tax code in shopify variant model (#108)
- Modifed the variant model to include the tax code.
- Added the tax code to existing unit test.
Latest commit 3bf7e10 May 3, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Linting any new code changes (#88) Sep 29, 2018
src CI-605 Include tax code in shopify variant model (#108) May 3, 2019
tests CI-605 Include tax code in shopify variant model (#108) May 3, 2019
.gitignore Updating PHP-CS-Fixer to allow PHP 7.2 (#92) Oct 2, 2018
.php_cs PHP-CS-Fixer fix ALL the things (#75) Jun 22, 2018
CODEOWNERS Update Craig's username in the CODEOWNERS file (#60) Mar 19, 2018
Dockerfile Make a phptest dockerfile (#86) Sep 29, 2018
LICENSE.md rename License file Jul 14, 2017
README.md Make a phptest dockerfile (#86) Sep 29, 2018
composer.json Mark as supporting Illuminate 5.8 (#106) Apr 17, 2019
composer.lock
phpunit.xml initial commit Jul 14, 2017
runtests.sh Make a phptest dockerfile (#86) Sep 29, 2018

README.md

Bold Shopify Toolkit

CircleCI

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);

    ...

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

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
You can’t perform that action at this time.