PHP code example of neimarperez / laravel-woocommerce

1. Go to this page and download the library: Download neimarperez/laravel-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/ */

    

neimarperez / laravel-woocommerce example snippets


php artisan vendor:publish --tag=woocommerce

use Codexshaper\WooCommerce\Facades\Product;

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

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

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

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

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

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

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

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

use Codexshaper\WooCommerce\Facades\Customer;

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

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

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