1. Go to this page and download the library: Download long-blade/shopify-plugin library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
long-blade / shopify-plugin example snippets
// src/Application.php in bootstrap() method
$this->addPlugin('Shopify');
use Shopify\Model\Site;
$siteId = 0; // a unique id (it can be the id of the entry in a database table)
$site = new Site('hostname', 'apiKey', 'apiPassword', $siteId);
use Shopify\Model\Site;
$site = new Site('hostname', 'apiKey', 'apiPassword', 0);
// Then use this object for any resource, for example:
use Shopify\Resource\Products;
$products = new Products($site);
use Shopify\Model\Site;
$site = new Site('hostname', 'apiKey', 'apiPassword', 0);
use Shopify\Resource\Shop;
$shop = new Shop($site);
// Then we perform a simple get request by chaining the getResource method
$shopInfo = $shop->getResource();
use Shopify\Resource\Products;
$productsResource = new Products($site);
//Retrieves a list of products
$products = $productsResource->getResource();
//Retrieves a single product
$product = $productsResource->getById(0102040506);
//Retrieves a list of product variants
$product = $productsResource->getVariantsForProduct(0102040506);
$productData = [
'title' => 'This is a product title',
'description' => 'This is a product description'
];
$product = new \Shopify\Model\Product($productData);
//Creates a new product by passing the product object created.
$productsResource->post($product);
// $productsResource = new Products($site);
$productsResource->export(['products' => [...]]);
[
'export' => [
'path' => RESOURCES . 'json' . DS,
'file_type' => 'json',
'lifetime' => 60 * 60 * 3, // The lifetime which a file is consider to be old
],
];
$inventory = [
'location_id' => 987654321, // The ID of the location that the inventory level belongs to.
'inventory_item_id' => 123456789, // The ID of the inventory item that the inventory level belongs to.
'available' => 10 // The quantity of inventory items available for sale.
];
$inventory = new \Shopify\Model\Inventory($inventory); // Create the entity;
$inventoryResource = new \Shopify\Resource\InventoryLevels($site);
$inventoryResource->setInventory($inventory);
$inventory = [
'location_id' => 987654321, // The ID of the location that the inventory level belongs to.
'inventory_item_id' => 123456789, // The ID of the inventory item that the inventory level belongs to.
'available_adjustment' => 5 // The amount to adjust the available inventory quantity. Send negative values to subtract from the current available quantity.
];
$inventory = new \Shopify\Model\Inventory($inventory); // Create the entity;
$inventoryResource = new \Shopify\Resource\InventoryLevels($site);
$inventoryResource->adjustInventory($inventory);
$orders = new Shopify\Resource\Orders($site);
// All orders
$allOrdersWithoutPagination = $orders->getPaginatedResource();
// All orders since Id:
$ordersSinsId= $orders->getOrdersSinceId(3692914802743);
use Shopify\Resource\SmartCollections;
$smrtCollections = new SmartCollections($site);
// This will return an array containing all the collections a product belongs to.
$collection = $smrtCollections->get(['product_id' => '12345678'])->getResource('smart_collections');
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.