corcel/woocommerce
A collection of Laravel models for WooCommerce.
This plugin extends base Corcel package and allows fetching WooCommerce data from WordPress database. Currently this plugin implements the following models:
- Customer - wrapper for User model
- Order - wrapper for Post model
- Product - wrapper for Post model
- Item
- Product Category - wrapper for Taxonomy model
- Product Tag - wrapper for Taxonomy model
- Product Attribute - helper model for getting product attributes (should not be used directly)
- Product Type - helper model for getting product types (should not be used directly)
Some meta values are collected into helper classes:
- BillingAddress - helper for customer and order billing address
- ShippingAddress - helper for customer and order shipping address
- Payment - helper for order payment
Compatibility list
| Corcel WooCommerce | Laravel | PHP version | Supported |
|---|---|---|---|
| 6.x (master) | 11.x, 12.x | >= 8.2 | :white_check_mark: |
| 5.x | 10.x, 11.x | >= 8.2 | :white_check_mark: |
| 4.x | 10.x | >= 8.1 | :x: |
| 3.x | 9.x | >= 8.0.3 | :x: |
| 2.x | 6.x, 7.x, 8.x | >= 7.3 | 8.0 | :x: |
| 1.x | 6.x, 7.x | >= 7.2 | :x: |
Installation
composer require corcel/woocommerce
Models list
Customer model
Get customer by id
$customer = Customer::find(1);
Customer relation
$customer = Customer::find(1);
$customerOrders = $customer->orders;
Customer properties
$customer = Customer::find(1);
$customer->order_count; // e.g. 10
$customer->billing_address; // \Corcel\WooCommerce\Support\BillingAddress class instance
$customer->shipping_address; // \Corcel\WooCommerce\Support\ShippingAddress class instance
Order model
Get order by id
$order = Order::find(1);
Get completed orders
$completedOrders = Order::completed()->get();
For other statuses methods please check OrderBuilder.php.
Order relations
$order = Order::find(1);
$orderItems = $order->items;
$orderCustomer = $order->customer;
Order properties
$order = Order::find(1);
$order->currency; // e.g. EUR
$order->total; // e.g. 10.20
$order->tax; // e.g. 0.50
$order->shipping_tax; // e.g. 0.20
$order->status; // e.g. completed
$order->date_completed; // e.g. 2020-06-01 10:00:00
$order->date_paid; // e.g. 2020-06-01 10:00:00
$order->payment; // \Corcel\WooCommerce\Support\Payment class instance
$order->billing_address; // \Corcel\WooCommerce\Support\BillingAddress class instance
$order->shipping_address; // \Corcel\WooCommerce\Support\ShippingAddress class instance
Item model
Get item by id
$item = Item::find(1);
Item relations
$item = Item::find(1);
$itemOrder = $item->order;
$itemProduct = $item->product;
Item properties
$item = Item::find(1);
$item->order_item_id;
$item->order_item_name;
$item->order_item_type;
$item->order_id;
$item->product_id;
$item->variation_id;
$item->quantity; // e.g. 2
$item->tax_class;
$item->line_subtotal; // e.g. 5.50
$item->line_subtotal_tax; // e.g. 0.50
$item->line_total; // e.g. 10.50
$item->line_tax; // e.g. 2.00
Product model
Get product by id
$product = Product::find(1);
Product relations
$product = Product::find(1);
$product->categories;
$product->items;
$product->tags;
Product properties
$product = Product::find(1);
$product->price;
$product->regular_price;
$product->sale_price;
$product->on_sale;
$product->sku;
$product->tax_status;
$product->is_taxable;
$product->weight;
$product->length;
$product->width;
$product->height;
$product->is_virtual;
$product->is_downloadable;
$product->stock;
$product->in_stock;
$product->type;
$product->attributes; // Collection of (variation) attributes
$product->crosssells; // Collection of cross-sell products
$product->upsells; // Collection of up-sell products
$product->gallery; // Collection of gallery attachments
Helper classes list
BillingAddress helper
This class collects customer and order meta related to billing address.
$order = Order::find(1);
$address = $order->billingAddress;
$address->first_name;
$address->last_name;
$address->company;
$address->address_1;
$address->address_2;
$address->city;
$address->state;
$address->postcode;
$address->country;
$address->email;
$address->phone;
ShippingAddress helper
This class collects customer and order meta related to billing address.
$order = Order::find(1);
$address = $order->shippingAddress;
$address->first_name;
$address->last_name;
$address->company;
$address->address_1;
$address->address_2;
$address->city;
$address->state;
$address->postcode;
$address->country;
Payment helper
This class collects order meta related to payment.
$order = Order::find(1);
$payment = $order->payment;
$payment->method;
$payment->method_title;
$payment->transaction_id;
Related Packages
Powerful PHP database abstraction layer (DBAL) with many features for database s...
Laravel Serializable Closure provides an easy and secure way to serialize closur...
Cli error handling for console/command-line PHP applications.
Version History
| Version | Released | PHP | Laravel | License |
|---|---|---|---|---|
| v6.0.0 | ^8.2 | ^11.0| | MIT | |
| v5.0.1 | ^8.2 | ^10.0| | MIT | |
| v5.0.0 | ^8.2 | ^10.0| | MIT | |
| v4.0.0 | ^8.1 | ^10.0 | MIT | |
| v3.0.0 | ^8.0.3 | ^9.0 | MIT | |
| v2.1.1 | ^7.3| | ^6.0| | MIT | |
| v2.1.0 | ^7.3| | ^6.0| | MIT | |
| v2.0.3 | ^7.3 | ^6.0| | MIT | |
| v2.0.2 | ^7.3 | ^6.0| | MIT | |
| v2.0.1 | ^7.3 | ^6.0| | MIT | |
| v2.0.0 | ^7.3 | ^6.0| | MIT | |
| v1.0.4 | ^7.2 | ^6.0| | MIT | |
| v1.0.3 | ^7.2 | ^6.0| | MIT | |
| v1.0.2 | ^7.2 | ^6.0| | MIT | |
| v1.0.1 | ^7.2 | ^6.0| | MIT | |
| v1.0.0 | ^7.2 | ^6.0| | MIT |