All Projects → pixelpeter → Laravel5 Woocommerce Api Client

pixelpeter / Laravel5 Woocommerce Api Client

Licence: mit
Laravel 5 wrapper for the Woocommerce REST API

Projects that are alternatives of or similar to Laravel5 Woocommerce Api Client

Laravel Woocommerce
WooCommerce Rest API for Laravel
Stars: ✭ 86 (-23.89%)
Mutual labels:  wordpress, woocommerce, laravel
Wl Bootstrap
Integrating Laravel into WordPress
Stars: ✭ 54 (-52.21%)
Mutual labels:  wordpress, laravel
Performance Improvements For Woocommerce
Performance tweaks for the front-end and back-end of a store.
Stars: ✭ 46 (-59.29%)
Mutual labels:  wordpress, woocommerce
Laravel Api Boilerplate Jwt
A Laravel 5.8 API Boilerplate to create a ready-to-use REST API in seconds.
Stars: ✭ 1,155 (+922.12%)
Mutual labels:  rest, laravel
Woocommerce
An open source eCommerce plugin for WordPress.
Stars: ✭ 7,473 (+6513.27%)
Mutual labels:  wordpress, woocommerce
Bitcoin Payments Woocommerce
Free Bitcoin/Altcoins Payment Gateway Addon for WooCommerce 2.1+ (or higher). Accept USD, Bitcoin, Litecoin, Dogecoin, Speedcoin, Darkcoin, Vertcoin, Reddcoin, Feathercoin, Vericoin, Potcoin payments in WooCommerce. Direct Integration on your website. No Chargebacks, Global, Secure. All in automatic mode.
Stars: ✭ 38 (-66.37%)
Mutual labels:  wordpress, woocommerce
Acf To Rest Api
Exposes Advanced Custom Fields Endpoints in the WordPress REST API
Stars: ✭ 1,152 (+919.47%)
Mutual labels:  rest, wordpress
Storefront
Official theme for WooCommerce
Stars: ✭ 762 (+574.34%)
Mutual labels:  wordpress, woocommerce
Wooshop
A Wocommerce Based React Native App for IOS and Android over GraphQL
Stars: ✭ 92 (-18.58%)
Mutual labels:  wordpress, woocommerce
Shadow Shop
Building highly customizable e-commerce websites selling shadowsocks services, using Wordpress and WooCommerce
Stars: ✭ 84 (-25.66%)
Mutual labels:  wordpress, woocommerce
Wordpress Rest Cache
WordPress Plugin to lazy cache HTTP requests in database and update via cron.
Stars: ✭ 8 (-92.92%)
Mutual labels:  rest, wordpress
Invoice As A Service
💰 Simple invoicing service (REST API): from JSON to PDF
Stars: ✭ 106 (-6.19%)
Mutual labels:  rest, laravel
Ddev
DDEV-Local: a local PHP development environment system
Stars: ✭ 915 (+709.73%)
Mutual labels:  wordpress, laravel
Osen Wc Mpesa
WordPress Plugin that extends WordPress and WooCommerce functionality to integrate MPESA for making payments, remittances, checking account balance transaction status and reversals.
Stars: ✭ 45 (-60.18%)
Mutual labels:  wordpress, woocommerce
Woocommerce Loadimpact
Scenarios for `loadimpact.com`, written against Liquid Web's WooCommerce sample data.
Stars: ✭ 17 (-84.96%)
Mutual labels:  wordpress, woocommerce
Dreamfactory
DreamFactory API Management Platform
Stars: ✭ 1,148 (+915.93%)
Mutual labels:  rest, laravel
Intervention
WordPress plugin to configure wp-admin and application state using a single config file.
Stars: ✭ 481 (+325.66%)
Mutual labels:  wordpress, woocommerce
Docksal
Unified, Docker 🐳 powered web development environment for macOS, Windows, and Linux
Stars: ✭ 505 (+346.9%)
Mutual labels:  wordpress, laravel
Db Seeder
A database seeder app for MySQL
Stars: ✭ 77 (-31.86%)
Mutual labels:  wordpress, laravel
Pilothouse
A command line app for managing a LEMP local development environment based on Docker.
Stars: ✭ 98 (-13.27%)
Mutual labels:  wordpress, laravel

Laravel 5 WooCommerce API Client

Latest Version on Packagist Software License Travis Build Scrutinizer Quality Scrutinizer Build SensioLabsInsight Total Downloads Coverage Status

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

Version overview

Laravel wc-api-php used Wordpress Woocommerce WC API version use branch
5.7+ 2.x 4.4+ 3.5+ v1, v2, v3 w.i.p.
5.5+ 1.3.x 4.4+ 3.0 - 3.4.x v1, v2, v3 ^3.0
5.4+ 1.3.x 4.4+ 2.6 - 2.6.14 v1, v2 ^2.0
5.3 1.3.x 4.1+ 2.1 - 2.5.5 legacy v1, legacy v2, legacy v3 ^1.0

Installation

Step 1: Install Through Composer

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

composer require pixelpeter/laravel5-woocommerce-api-client ^3.0

For API Version v1, WooCommerce 2.6+, Wordpress 4.4+, Laravel 5.4+ use the v2.x branch

composer require pixelpeter/laravel5-woocommerce-api-client ^2.0

For older versions of Woocommerce starting from 2.1+ use the v1.x branch

composer require pixelpeter/laravel5-woocommerce-api-client ^1.0

Step 2: Add the Service Provider (not needed with v3.x)

Add the service provider in app/config/app.php

'provider' => [
    ...
    Pixelpeter\Woocommerce\WoocommerceServiceProvider::class,
    ...
];

Step 3: Add the Facade (not needed with v3.x)

Add the alias in app/config/app.php

'aliases' => [
    ...
    'Woocommerce' => Pixelpeter\Woocommerce\Facades\Woocommerce::class,
    ...
];

Step 4: Publish configuration

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

Step 5: 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_CONSUMER_KEY=ck_your-consumer-key
WOOCOMMERCE_CONSUMER_SECRET=cs_your-consumer-secret
WOOCOMMERCE_VERIFY_SSL=false
WOOCOMMERCE_VERSION=v1
WOOCOMMERCE_WP_API=true
WOOCOMMERCE_WP_QUERY_STRING_AUTH=false
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

For legacy API versions

(WC 2.4.x or later, WP 4.1 or later) use this syntax

use Woocommerce;

$data = [
    'status' => 'completed',
    'filter' => [
        'created_at_min' => '2016-01-14'
    ]
];

$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
}

For current API versions

(WC 2.6.x or later, WP 4.4 or later) use this syntax. after needs to be a ISO-8601 compliant date!≠

use Woocommerce;

$data = [
    'status' => 'completed',
    'after' => '2016-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)

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

Woocommerce::totalResults(); // 474
Woocommerce::firstPage(); // 1
Woocommerce::lastPage(); // 19
Woocommerce::currentPage(); // 5 
Woocommerce::totalPages(); // 19
Woocommerce::previousPage(); // 4
Woocommerce::nextPage(); // 6
Woocommerce::hasPreviousPage(); // true 
Woocommerce::hasNextPage(); // true
Woocommerce::hasNotPreviousPage(); // false 
Woocommerce::hasNotNextPage(); // false

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.

Testing

Run the tests with:

vendor/bin/phpunit

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].