PHP code example of trexology / laravel-order

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

    

trexology / laravel-order example snippets


    return [

        /*
        |--------------------------------------------------------------------------
        | Order Status Name
        |--------------------------------------------------------------------------
        | Customize the status name recorded
        |
        */

        'init' => "init",
        'complete' => "complete",

        'ignoredFields' => []

    ];

    $data = [
        //Custom fields
        'cust_first_name' => $cust->first_name,
        'cust_last_name' => $cust->last_name
    ];

    $order = Order::order($cust->id, $data);

    $data = [
      'description' => "My item descriptions",
      'currency' => "SGD"
    ];
    $order = Order::addItem($order, $object, 25.5, 2, $data, 7);

    $data = [
      'description' => "My item descriptions",
      'currency' => "SGD"
    ];
    $order = Order::addItem($order, 22, "App\Model\Object", 25.5, 2, $data, 7);

    $order_Items = [
        [
            "description" => "Some Description",
            "currency" => "USD",
            "line_item_id" => 1,
            "line_item_type" => "App\\Models\\Package",
            "price" => 1802,
            "quantity" => 1,
            "vat" => 0,
        ],
        [
            "description" => "Some Description",
            "currency" => "USD",
            "line_item_id" => 1,
            "line_item_type" => "App\\Models\\Package",
            "price" => 1802,
            "quantity" => 1,
            "vat" => 0,
        ]
    ];
    $order = Order::batchAddItems($order, $order_Items);

    Order Order::getOrder(int $order_id);

    Collection Order::getUserOrders(int $user_id);

    boolean Order::updateStatus(int $order_id, string $status);

    boolean Order::deleteOrder(int $order_id);

    OrderItem Order::updateQty(int $item_id, int qty);

    float Order::total(Order $order);

    int Order::count(Order $order);