jeppos/shopify-php-sdk

一个易于使用的 Shopify PHP SDK。

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

This package is auto-updated.

Last update: 2024-09-27 21:34:59 UTC


README

一个易于使用的 Shopify PHP SDK。

Codacy Badge Build Status Codacy Badge

安装

Composer

composer require jeppos/shopify-php-sdk

使用

配置

根据 Shopify 官方文档中的说明(Shopify's own documentation)创建一个私有应用,以生成所需的凭证。

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

属性

ShopifySDK 类具有以下属性:

示例

获取单个产品

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

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

获取自定义系列列表

// 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;
}

创建产品

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

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