jeppos/shopify-php-sdk

An easy to use Shopify PHP SDK.

v0.1 2017-11-04 13:33 UTC

This package is auto-updated.

Last update: 2024-04-27 20:29:29 UTC


README

An easy to use Shopify PHP SDK.

Codacy Badge Build Status Codacy Badge

Installation

Composer

composer require jeppos/shopify-php-sdk

Usage

Configure

Create a private app using the instructions found on Shopify's own documentation, to generate the required credentials.

<?php

include __DIR__ . '/vendor/autoload.php';
\Doctrine\Common\Annotations\AnnotationRegistry::registerLoader('class_exists');

$shopifySDK = new \Jeppos\ShopifySDK\ShopifySDK('your-store-name.myshopify.com', 'api-key', 'api-secret');

Properties

The ShopifySDK class has the following properties,

Examples

Fetch single product

// Get a Product class
$product = $shopifySDK->products->getOne(123);

// Display the product title
echo $product->getTitle();

Fetch a list of custom collections

// Get an array of CustomCollection classes
$customCollections = $shopifySDK->customCollections->getList(); 

// Display the title of each custom collection on a new line
foreach ($customCollections as $customCollection) {
    echo $customCollection->getTitle() . PHP_EOL;
}

Create a product

$product = new Product();
$product->setTitle('My new product');

$shopifySDK->products->createOne($product);