Skip to content

jeppos/shopify-php-sdk

Repository files navigation

shopify-php-sdk

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