PHPackages                             crazymeeks/php-shopify - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. crazymeeks/php-shopify

ActiveLibrary[API Development](/categories/api)

crazymeeks/php-shopify
======================

PHP API for shopify

v1.0.0(5y ago)1111MITPHP

Since Feb 23Pushed 5y ago1 watchersCompare

[ Source](https://github.com/crazymeeks/php-shopify)[ Packagist](https://packagist.org/packages/crazymeeks/php-shopify)[ RSS](/packages/crazymeeks-php-shopify/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

PHP Shopify
-----------

[](#php-shopify)

PHP Shopify is a library that provides simple yet Object Oriented way
of interacting with [Shopify](https://www.shopify.com.ph/).

\# Requirements
---------------

[](#-requirements)

- PHP 7.x

\# Installation
---------------

[](#-installation)

Copy and paste this in your terminal `composer require crazymeeks/php-shopify`

\# Available APIs
-----------------

[](#-available-apis)

- App installation
- Customer
- Collection/Collect/Product
- Order
- ScriptTag

\# Configuration/Setup
----------------------

[](#-configurationsetup)

In order to use this library, a minimal configration is need. We will be creating two class.
Let's call it `ConfigContext` and `InstallContext`.
`ConfigContext` must implement `\Crazymeeks\App\Contracts\ShopifyConfigContextInterface` and `InstallContext` must implement `Crazymeeks\App\Contracts\InstallContextInterface`.
Note: You may name your classes to whatever you want.
Please follow instruction properly and you'll be good to go!

1. ConfigContext

```
namespace Some\Name\Space;

use Crazymeeks\App\Contracts\ShopifyConfigContextInterface;

class ConfigContext implements ShopifyConfigContextInterface
{
    /**
     * @implement
     */
    public function getApiKey(): string
    {
        return 'your-shopify-api-key-here';
    }

    /**
     * @implement
     */
    public function getSecretKey(): string
    {
        return 'your-shopify-secret-key-here';
    }

    /**
     * @implement
     */
    public function getVersion(): string
    {
        return '2021-01';
    }
}
```

2. InstallContext

```
namespace Your\Name\Space;

use Crazymeeks\App\Contracts\InstallContextInterface;

class InstallContext implements InstallContextInterface
{
    /**
     * @implemented
     */
    public function getScopes(): array
    {
        // You may add as many scopes as you want here
        return [
            'read_orders',
            'write_products',
        ];
    }

    /**
     * @implemented
     */
    public function getRedirectUri(): string
    {
        // The url of your website that will be use by shopify
        // during installation of your shopify app
        return 'https://mywebsite.com/app/generate-token';
    }
}
```

\# Let someone install your app!
--------------------------------

[](#-let-someone-install-your-app)

In order for your app to communicate with Shopify, it has to be installed on shopify.
Just instantiate `Crazymeeks\App\Shopify` and call its `install()` method.
The 1st argument you would need to pass in this method is the instance of `InstallContext`
you just defined above. The 2nd argument would be the url of your shopify store like `test.myshopify.com`.
That's it! You will be redirected to your shopify store to continue the installation.

```
$shopify = new \Crazymeeks\App\Shopify();

$shopify->install(new InstallContext(), 'test.myshopify.com');
```

\# Get Access Token
-------------------

[](#-get-access-token)

When your app is installed into shopify, shopify will load your app into
its Dashboard(iframed) along with these important parameters: `hmac`, `code`, `shop`, `timestamp`.
You need these parameters in order to get an access token for your app.
You are required to pass these in the `setData()` method of `Crazymeeks\App\Shopify::class`.
We will use `\Crazymeeks\App\Resource\Action\GetShopAccessToken:class` as our action.

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetShopAccessToken())
                    ->setData([
                        'hmac' => 'a3cc315a829340ab014e7f5aa8eabe83f9cfeaf4b9eb6c17f04c85cabf188729',
                        'code' => '6a94694acf0339e9eb8068d8f4718eea',
                        'shop' => 'test.myshopify.com',
                        'timestamp' => '1610955131',
                    ])
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
// echo access_token and scope,
// you must save the response' access token
// for future use
echo 'Access Token: ' . $response->access_token . 'Scope: ' . $response->scope;
```

\# Customer API
---------------

[](#-customer-api)

Use to manage customer data. Please refer to shopify's [documentation](https://shopify.dev/docs/admin-api/rest/reference) for the response and other details.
**Create Customer** - When creating a customer to shopify, you just need to instantiate `\Crazymeeks\App\Resource\Action\CreateCustomer::class`
and pass it as an argument to `setAction()` of `\Crazymeeks\App\Shopify::class`

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\CreateCustomer())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setData([
                        'first_name' => 'John',
                        'last_name' => 'Doe',
                        'email' => 'john.doe@example.com',
                        'verified_email' => true,
                        'send_email_welcome' => false,
                        'password' => 'test123123',
                        'password_confirmation' => 'test123123',
                    ])
                    ->execute();
```

**Search Customer**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\SearchCustomer())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setData('email:john.doe@example.com')
                    ->execute();
```

**Retrieve Single Customer**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetCustomer())
                    ->setAccessToken('your-access-token')
                    ->setResourceId('207119551')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

**Customer email domain whitelisting**
You may also whitelist the list of email domain you wish to allow when adding/creating a customer.
For example, if you want to allow only all email with the domain `@gmail.com`,
just call `setWhitelistedEmailDomains()`. This method accepts an array. Thus,
you may whitelist as many email domain as you want!

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetCustomer())
                    ->setAccessToken('your-access-token')
                    ->setResourceId('207119551')
                    ->setShopUrl('test.myshopify.com')
                    ->setWhitelistedEmailDomains(['@gmail.com', '@hotmail.com'])
                    ->execute();
```

\# Collect API
--------------

[](#-collect-api)

According to [shopify](https://shopify.dev/docs/admin-api/rest/reference/products/collect), Collects are meant for managing the relationship between products and custom collections. **Get Collect List**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetCollect())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

**Get Collect By ID**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetCollect())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('455204334')
                    ->execute();
```

**Get Collect Count**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\CollectCount())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

Collection API
--------------

[](#collection-api)

According to [shopify](https://shopify.dev/docs/admin-api/rest/reference/products/collection), A collection is a grouping of products that merchants can create to make their stores easier to browse. For example, a merchant might create a collection for a specific type of product that they sell, such as Footwear.

**Retrieve a list of products belonging to a collection**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetProductCollections())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('239222980791')
                    ->setPerPage(10) // Optional only
                    ->execute();
```

**Retrieve single collection**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetCollection())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('841564295')
                    ->execute();
```

**Add Product to a collection**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\AddProductToCollection())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setData([
                        'product_id' => 921728736,
                        'collection_id' => 841564295,
                    ])
                    ->execute();
```

**Delete Product from collection**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\DeleteProductToCollection())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setData('455204334')
                    ->execute();
```

\# Orders API
-------------

[](#-orders-api)

According to [shopify](https://shopify.dev/docs/admin-api/rest/reference/orders), Order API give merchants new ways to receive, process, and manage their orders.
**Retrieve Orders**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetOrder())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setStatus(\Crazymeeks\App\Resource\Action\GetOrder::CANCELLED) // Optional. Other status are: CLOSED, OPEN
                    ->setFinancialStatus(\Crazymeeks\App\Resource\Action\GetOrder::FIN_ANY) // Optional. Other financial status are: FIN_AUTHORIZED, FIN_PENDING, FIN_PAID, FIN_PARTIALLY_PAID, FIN_REFUNDED, FIN_VOIDED, FIN_PARTIALLY_REFUNDED, FIN_UNPAID
                    ->setFulfillmentStatus(\Crazymeeks\App\Resource\Action\GetOrder::FFMT_ANY) // Optional. Other fulfillment status are: FFMT_SHIPPED, FFMT_PARTIAL, FFMT_UNSHIPPED, FFMT_UNFULFILLED
                    ->setPerPage(5) // Optional
                    ->execute();
```

**Retrieve Single Order**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetOrder())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('450789469')
                    ->execute();
```

**Retrieve Order Count**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetOrderCount())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

**Closing an Order**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\CloseOrder())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('450789469')
                    ->execute();
```

**Opening an Order**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\ReOpenOrder())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('450789469')
                    ->execute();
```

**Cancelling an Order**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\CancelOrder())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('450789469')
                    ->execute();
```

\# Script Tag API
-----------------

[](#-script-tag-api)

According to [shopify](https://shopify.dev/docs/admin-api/rest/reference/online-store/scripttag), the ScriptTag resource represents remote JavaScript code that is loaded into the pages of a shop's storefront or the order status page of checkout. This lets you add functionality to those pages without using theme templates.

**Create Script Tag**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\CreateScriptTag())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setData('https://myweb.com/script.js')
                    ->execute();
```

**Retrieve Script Tags**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\GetScriptTags())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

**Update Script Tag**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\UpdateScriptTag())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('596726825')
                    ->setData('https://myweb.com/script.js')
                    ->execute();
```

**Delete Script Tag**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\DeleteScriptTag())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->setResourceId('596726825')
                    ->execute();
```

**Retreive count of Script Tag**

```
$shopify = new \Crazymeeks\App\Shopify(new ConfigContext());
$response = $shopify->setAction(new \Crazymeeks\App\Resource\Action\ScriptTagCount())
                    ->setAccessToken('your-access-token')
                    ->setShopUrl('test.myshopify.com')
                    ->execute();
```

### Author

[](#author)

Jeff Claud

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity52

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

1910d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/07c8c7c06de29afbc4fbc9e66f5fcc320c499057969ce341730590355d6d6145?d=identicon)[jepoy](/maintainers/jepoy)

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/crazymeeks-php-shopify/health.svg)

```
[![Health](https://phpackages.com/badges/crazymeeks-php-shopify/health.svg)](https://phpackages.com/packages/crazymeeks-php-shopify)
```

###  Alternatives

[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[hubspot/api-client

Hubspot API client

23414.2M16](/packages/hubspot-api-client)[ixudra/toggl

Custom PHP library to connect with the Toggl API - developed by Ixudra

27115.5k1](/packages/ixudra-toggl)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
