PHPackages                             neimarperez/laravel-woocommerce - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. neimarperez/laravel-woocommerce

ActiveLibrary[API Development](/categories/api)

neimarperez/laravel-woocommerce
===============================

WooCommerce Rest API with Laravel

v2.0.0(4y ago)0230MITPHP

Since Apr 9Pushed 4y agoCompare

[ Source](https://github.com/neimarperez/laravel-woocommerce)[ Packagist](https://packagist.org/packages/neimarperez/laravel-woocommerce)[ RSS](/packages/neimarperez-laravel-woocommerce/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (18)Used By (0)

Laravel Woocommerce
===================

[](#laravel-woocommerce)

WooCommerce Rest API for Laravel. You can Get, Create, Update and Delete your woocommerce product using this package easily.

\#Install

```
composer require codexshaper/laravel-woocommerce

```

\#Publish config file

```
php artisan vendor:publish --tag=woocommerce

```

\#Add API credentials in your `.env` file

```
WOOCOMMERCE_STORE_URL=YOUR_WEBSITE_URL
WOOCOMMERCE_CONSUMER_KEY=API_CONSUMER_KEY
WOOCOMMERCE_CONSUMER_SECRET=API_CONSUMER_SECRET

```

\#Do you need any help to create your own API credentials? Read the officials Doc

Example for Product
===================

[](#example-for-product)

\#Retrieve Product(s)

```
use Codexshaper\WooCommerce\Facades\Product;

public function products()
{
  return Product::all();
}

public function product( Request $request )
{
  $product = Product::find($request->id);
}

```

\#Create new Product

```
// For Simple Product
$data = [
    'name'              => 'Simple Product', // Product Name or Title
    'type'              => 'simple', // Product type simple|variable
    'regular_price'     => '100', // Regular Price
    'sale_price'        => '', // Price after offer
    'description'       => 'Product Description', // Product Long Description
    'short_description' => 'Product Short Description', // Product Short Description
    // Set Categories as an array
    'categories'        => [
        [
            'id' => 1,
        ],
        [
            'id' => 3,
        ],
    ],
    // Set thumnail images as an array
    'images'            => [
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
        ],
        [
            'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
        ],
    ],
];

// For Variable Product
$data = [
            'name'               => 'Variable Product', // Product Name pr Title
            'type'               => 'variable', // Product Type simple|variable
            'description'        => 'Product Description', // Product Long Description
            'short_description'  => 'Product Summery', // Product Short Description
            // Product Categories
            'categories'         => [
                [
                    'id' => 9,
                ],
                [
                    'id' => 14,
                ],
            ],
            // Product images
            'images'             => [
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_front.jpg',
                ],
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_4_back.jpg',
                ],
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_front.jpg',
                ],
                [
                    'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_3_back.jpg',
                ],
            ],
            // Product Attributes
            'attributes'         => [
                [
                    'id'        => 6,
                    'position'  => 0,
                    'visible'   => false,
                    'variation' => true,
                    'options'   => [
                        'Black',
                        'Green',
                    ],
                ],
                [
                    'name'      => 'Size',
                    'position'  => 0,
                    'visible'   => true,
                    'variation' => true,
                    'options'   => [
                        'S',
                        'M',
                    ],
                ],
            ],
            // Set Default attributes
            'default_attributes' => [
                [
                    'id'     => 6,
                    'option' => 'Black',
                ],
                [
                    'name'   => 'Size',
                    'option' => 'S',
                ],
            ],
        ];

// Create a product using create() method
$product = Product::create($data);

// Create a product using save() method
$categories = [
    [
        'id' => 1,
    ],
    [
        'id' => 3,
    ],
];

$images = [
    [
        'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_front.jpg',
    ],
    [
        'src' => 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
    ],
];

$product                    = new Product;
$product->name              = 'Product Eloquent 2';
$product->type              = 'simple';
$product->regular_price     = '100';
$product->sale_price        = '50';
$product->description       = 'Product Description';
$product->short_description = 'Product Short Description';
$product->categories        = $categories;
$product->images            = $images;
$product->save();

```

\#Update existing Product

```
$product_id = 40;
$data       = [
    'regular_price' => '50',
    'sale_price'    => '25', // 50% off
];

$product = Product::update($product_id, $data);

```

\#Delete a Product

```
$product_id = 40;

$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$product = Product::delete($product_id, $options);

```

Example for Order
=================

[](#example-for-order)

\#Create Order

```
$data = [
    'payment_method'       => 'bacs',
    'payment_method_title' => 'Direct Bank Transfer',
    'set_paid'             => true,
    'billing'              => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
        'email'      => 'john.doe@example.com',
        'phone'      => '(555) 555-5555',
    ],
    'shipping'             => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
    ],
    'line_items'           => [
        [
            'product_id' => 40,
            'quantity'   => 2,
        ],
        [
            'product_id'   => 127,
            'variation_id' => 23,
            'quantity'     => 1,
        ],
    ],
];

$order = Order::create($data);

```

\#Retrieve Order(s)

```
use Codexshaper\WooCommerce\Facades\Order;

public function orders()
{
  $orders = Order::all();
}

public function order( Request $request )
{
  $order = Order::find($request->id);
}

```

\#Update Order

```
$order_id = 173;
$data     = [
    'status' => 'completed',
];

$order = Order::update($order_id, $data);

```

\#Delete an order

```
$order_id = 173;
$options = ['force' => true]; // Set force option true for delete permanently. Default value false

$order = Order::delete($order_id, $options);

```

\#Create a note for a specific order

```
$order_id = 172;
$data = [
    'note' => 'Add your note',
];
$createNote = Order::createNote($order_id, $data);

```

\#Get a note for sepcific order

```
$order_id = 172;
$note_id  = 67;

$note = Order::note($order_id, $note_id);

```

\#Get all notes for sepcific order

```
$order_id = 172;
$options = [];
$notes = Order::notes($order_id, $options);

```

\#Delete a note for sepcific order

```
$order_id = 172;
$note_id  = 67;
$options = [];

$note = Order::deleteNote($order_id, $note_id, $options);

```

\#Create a Refund for a specific order

```
$order_id = 172;
$data = [
    'amount' => '10'
];
$createNote = Order::createRefund($order_id, $data);

```

\#Get Refund for sepcific order

```
$order_id = 172;
$refund_id  = 117;

$refund = Order::refund($order_id, $refund_id);

```

\#Get all Refunds for sepcific order

```
$order_id = 172;
$options = [];
$refunds = Order::refunds($order_id, $options);

```

\#Delete Refund for sepcific order

```
$order_id = 172;
$refund_id  = 67;
$options = [];

$refund = Order::deleteRefund($order_id, $refund_id, $options);

```

Example for Customer
====================

[](#example-for-customer)

\#Create Customer

```
$data = [
    'email'      => 'john.doe@example.com',
    'first_name' => 'John',
    'last_name'  => 'Doe',
    'username'   => 'john.doe',
    'billing'    => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'company'    => '',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
        'email'      => 'john.doe@example.com',
        'phone'      => '(555) 555-5555',
    ],
    'shipping'   => [
        'first_name' => 'John',
        'last_name'  => 'Doe',
        'company'    => '',
        'address_1'  => '969 Market',
        'address_2'  => '',
        'city'       => 'San Francisco',
        'state'      => 'CA',
        'postcode'   => '94103',
        'country'    => 'US',
    ],
];
$customer = Customer::create($data);

```

\#Retreive Customer(s)

```
use Codexshaper\WooCommerce\Facades\Customer;

public function customers()
{
  return Customer::all();
}

public function customer( Request $request )
{
  $customer = Customer::find($request->id);
}

```

\#Update Customer

```
$customer_id = 2;
$data        = [
    'first_name' => 'James',
    'billing'    => [
        'first_name' => 'James',
    ],
    'shipping'   => [
        'first_name' => 'James',
    ],
];

$customer = Customer::update($customer_id, $data);

```

\#Delete Customer

```
$customer_id = 2;
$options     = ['force' => true]; // Set force option true for delete permanently. Default value false

$customer = Customer::delete($customer_id, $options);

```

Eloquent Style for Product, Customer and Order
==============================================

[](#eloquent-style-for-product-customer-and-order)

```
// Where passing multiple parameters
$orders = Order::where('status', 'publishing')->get();
$orders = Order::where('total', '>=', 10)->get();

// Where passing an array
$orders = Order::where(['status' => 'processing']);
$orders = Order::where(['status' => 'processing', 'orderby' => 'id', 'order' => 'asc'])->get();

// Order with where
$orders = Order::where('total', '>=', 10)->orderBy('id', 'asc')->get();

// Set Options
$orders = Order::options(['status' => 'processing', 'orderby' => 'id', 'order' => 'asc'])->get();

// You can set options by passing an array when call `all` method
$orders = Order::all(['status' => 'processing', 'orderby' => 'id', 'order' => 'asc']);

```

\#Product Options:

\#Customer Options:

\#Order Options:

You can also use `WooCommerce` Facade
=====================================

[](#you-can-also-use-woocommerce-facade)

```
use Codexshaper\WooCommerce\Facades\WooCommerce;

public function products()
{
  return WooCommerce::all('products');
}

public function product( Request $request )
{
  $product = WooCommerce::find('products/'.$request->id);
}

public function orders()
{
  return WooCommerce::all('orders');
}

public function order( Request $request )
{
  $order = WooCommerce::all('orders/'.$request->id);
}

public function customers()
{
  return WooCommerce::all('customers');
}

public function customer( Request $request )
{
  $customer = WooCommerce::all('customers/'.$request->id);
}

```

Use Facade Alias
================

[](#use-facade-alias)

```
use WooCommerce // Same as use Codexshaper\WooCommerce\Facades\WooCommerce;
use Customer // Same as use Codexshaper\WooCommerce\Models\Customer;
use Order // Same as use Codexshaper\WooCommerce\Models\Order;
use Product // Same as Codexshaper\WooCommerce\Models\Product;

```

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 79.2% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~56 days

Recently: every ~181 days

Total

17

Last Release

1744d ago

Major Versions

v1.1.8 → v2.0.02021-09-23

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1771209?v=4)[Neimar Perez](/maintainers/neimarperez)[@neimarperez](https://github.com/neimarperez)

---

Top Contributors

[![Codexshaper](https://avatars.githubusercontent.com/u/49456098?v=4)](https://github.com/Codexshaper "Codexshaper (42 commits)")[![maab16](https://avatars.githubusercontent.com/u/20833514?v=4)](https://github.com/maab16 "maab16 (11 commits)")

---

Tags

laravelwoocommercelaravel-woocommercewoocommerce-apiwoocommerce-rest-apilaravel-woocommerce-apilaravel-woocommerce-rest-api

### Embed Badge

![Health badge](/badges/neimarperez-laravel-woocommerce/health.svg)

```
[![Health](https://phpackages.com/badges/neimarperez-laravel-woocommerce/health.svg)](https://phpackages.com/packages/neimarperez-laravel-woocommerce)
```

###  Alternatives

[codexshaper/laravel-woocommerce

WooCommerce Rest API for Laravel

208173.1k](/packages/codexshaper-laravel-woocommerce)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
