定制 hexboy/laravel-woocommerce-api-client 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

hexboy/laravel-woocommerce-api-client

Composer 安装命令:

composer require hexboy/laravel-woocommerce-api-client

包简介

Laravel 5 wrapper for the Woocommerce REST API

README 文档

README

A simple Laravel 5 wrapper for the official WooCommerce REST API PHP Library from Automattic.

Installation

Step 1: Install Through Composer

For API Version v3, WooCommerce 3.0+, Wordpress 4.4+, php 7.0+, Laravel 5.5+ use the v3.x branch

composer require hexboy/laravel-woocommerce-api-client ^2.0

Step 2: Publish configuration

php artisan vendor:publish --provider="Hexboy\Woocommerce\WoocommerceServiceProvider"

Step 3: Customize configuration

You can directly edit the configuration in config/woocommerce.php or copy these values to your .env file.

WOOCOMMERCE_STORE_URL=http://example.org
WOOCOMMERCE_VERIFY_SSL=false
WOOCOMMERCE_VERSION=v3
WOOCOMMERCE_WP_API=true
WOOCOMMERCE_AUTH_TYPE=JWT
WOOCOMMERCE_WP_TIMEOUT=15

Examples

Get the index of all available endpoints

use Woocommerce;

return Woocommerce::get('');

View all orders

use Woocommerce;

return Woocommerce::get('orders');

View all completed orders created after a specific date

after needs to be a ISO-8601 compliant date!≠

use Woocommerce;

$data = [
    'status' => 'completed',
    'after' => '2019-01-14T00:00:00'
    ]
];

$result = Woocommerce::get('orders', $data);

foreach($result['orders'] as $order)
{
    // do something with $order
}

// you can also use array access
$orders = Woocommerce::get('orders', $data)['orders'];

foreach($orders as $order)
{
    // do something with $order
}

Update a product

use Woocommerce;

$data = [
    'product' => [
        'title' => 'Updated title'
    ]
];

return Woocommerce::put('products/1', $data);

Pagination

So you don't have to mess around with the request and response header and the calculations this wrapper will do all the heavy lifting for you. (WC 2.6.x or later, WP 4.4 or later)

Laravel LengthAwarePaginator

use Woocommerce;

$params = [
    'per_page' => 25, 
    'page' => 5
];

// or

$params = [];

$products = Woocommerce::get('products', $params, true);
$products->withPath('custom/url');
return $products;

raw pagination data

use Woocommerce;

// assuming we have 474 orders in pur result
// we will request page 5 with 25 results per page
$params = [
    'per_page' => 25,
    'page' => 5
];

Woocommerce::get('orders', $params);

HTTP Request & Response (Headers)

use Woocommerce;

// first send a request
Woocommerce::get('orders');

// get the request
Woocommerce::getRequest();

// get the response headers
Woocommerce::getResponse();

// get the total number of results
Woocommerce::getResponse()->getHeaders()['X-WP-Total']

More Examples

Refer to WooCommerce REST API Documentation for more examples and documention.

License

The MIT License (MIT). Please see License File for more information.

hexboy/laravel-woocommerce-api-client 适用场景与选型建议

hexboy/laravel-woocommerce-api-client 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 117 次下载、GitHub Stars 达 4, 最近一次更新时间为 2019 年 04 月 22 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「rest」 「shop」 「ecommerce」 「api」 「cart」 「wordpress」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 hexboy/laravel-woocommerce-api-client 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 hexboy/laravel-woocommerce-api-client 我们能提供哪些服务?
定制开发 / 二次开发

基于 hexboy/laravel-woocommerce-api-client 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 117
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 10
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 4
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2019-04-22