jeppos / shopify-php-sdk
一个易于使用的 Shopify PHP SDK。
v0.1
2017-11-04 13:33 UTC
Requires
- php: ^7.1
- consistence/consistence-jms-serializer: ^1.0
- doctrine/common: ^2.7
- guzzlehttp/guzzle: ^6.2
- jms/serializer: ^1.6
Requires (Dev)
- codacy/coverage: ^1.1
- phpmd/phpmd: ^2.6
- phpunit/phpunit: ^6.1
- squizlabs/php_codesniffer: ^3.0
This package is auto-updated.
Last update: 2024-09-27 21:34:59 UTC
README
一个易于使用的 Shopify PHP SDK。
安装
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 类具有以下属性:
- products - 返回 ProductService 实例
- collects - 返回 CollectService 实例
- customCollections - 返回 CustomCollectionService 实例
- productImages - 返回 ProductImageService 实例
- productVariants - 返回 ProductVariantService 实例
示例
获取单个产品
// 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);