PHP code example of corcel / woocommerce

1. Go to this page and download the library: Download corcel/woocommerce library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

corcel / woocommerce example snippets


$customer = Customer::find(1);

$customer = Customer::find(1);

$customerOrders = $customer->orders;

$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 = Order::find(1);

$completedOrders = Order::completed()->get();

$order = Order::find(1);

$orderItems    = $order->items;
$orderCustomer = $order->customer;

$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 = Item::find(1);

$item = Item::find(1);

$itemOrder   = $item->order;
$itemProduct = $item->product;

$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 = Product::find(1);

$product = Product::find(1);

$product->categories;
$product->items;
$product->tags;

$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

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

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

$order   = Order::find(1);
$payment = $order->payment;

$payment->method;
$payment->method_title;
$payment->transaction_id;