upgradelabs / laravel-woocommerce
WooCommerce Rest API for Laravel
1.0.5
2023-10-20 21:38 UTC
Requires
- automattic/woocommerce: ^3.0
Requires (Dev)
- illuminate/support: ~5.5.40|~5.6.0|~5.7.0|~5.8.0|^6.0|^7.0|^8.0|^9.0|^10
- phpunit/phpunit: ^7.0|^8.0|^9.3|^10|^11
README
Description
WooCommerce Rest API for Laravel. You can Get, Create, Update and Delete your woocommerce product using this package easily.
Authors
- Md Abu Ahsan Basir - github
License
- MIT license
- Copyright 2020 © CodexShaper.
Eloquent Style for Product, Customer and Order
//This fork allows to use several WooCommerce Sites.
//You can have a Dashboard to manage several WooCommerce
//Before use you need to specify which WooCommerce site you´re using.
//Just bind to the app container
app()->bind(WooCommerceApi::class, fn() => new WooCommerceApi('site_name_in_the_config_file'));
// Where passing multiple parameters
$products = Product::where('title','hello')->get();
OR
// You can call field with where clause
$products = Product::whereTitle('hello')->get();
// Fields name are more than one words or seperate by underscore (_). For example field name is `min_price`
$products = Product::whereMinPrice(5)->get();
// Where passing an array
$orders = Order::where(['status' => 'processing']);
$orders = Order::where(['status' => 'processing', 'orderby' => 'id', 'order' => '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: https://woocommerce.github.io/woocommerce-rest-api-docs/#products
#Customer Options: https://woocommerce.github.io/woocommerce-rest-api-docs/#customers
#Order Options: https://woocommerce.github.io/woocommerce-rest-api-docs/#orders
You can also use WooCommerce
Facade
use Upgradelabs\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 WooCommerce // Same as use Upgradelabs\WooCommerce\Facades\WooCommerce;
use Customer // Same as use Upgradelabs\WooCommerce\Models\Customer;
use Order // Same as use Upgradelabs\WooCommerce\Models\Order;
use Product // Same as Upgradelabs\WooCommerce\Models\Product;