industrious / coreprint-php
Coreprint API 的 PHP 封装
dev-master
2018-09-17 15:35 UTC
Requires
- php: ^7.0
- guzzlehttp/guzzle: ^6.3
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.0
- phpunit/phpunit: ^6.0
This package is auto-updated.
Last update: 2024-09-29 05:08:32 UTC
README
Coreprint API 的 PHP 封装。封装使用动态 __call 方法,因此您可以调用 CorePrint 的任何方法,以下是一些示例。
入门指南
安装包
$ composer require industrious/coreprint-php
用法
添加到购物车
$product_id = 1; $basket = (new Industrious\CorePrint\CorePrint) ->addBasketEntry('PUT', [ [ 'productid' => $product_id, 'quantity' => 1, 'itemurl' => 'https://placehold.it/100x100', ] ]);
添加地址
$address = (new Industrious\CorePrint\CorePrint) ->addAddress('PUT', [ [ 'type' => 1, 'label' => 'Delivery Address', 'deliverto' => 'FULL_NAME', 'streets' => (object) [ 'Address Line 1', 'Address Line 2', ], 'city' => 'City', 'state' => 'County', 'postcode' => 'Post Code', 'country' => 'United Kingdom' ] ]);
创建订单
$basket_id = 1; $invoice_address_id = 1; $address_id = 1; $order = (new Industrious\CorePrint\CorePrint) ->createOrder('PUT', [ 'entries' => (object) [$basket_id], 'invoice' => $invoice_address_id, 'delivery' => $address_id, ]);