> ## Documentation Index
> Fetch the complete documentation index at: https://docs.lunarphp.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Extending Orders

The order creation process can be customized using pipelines.

## Overview

If you want to add additional functionality to the Order creation process, you can do so using pipelines.

## Pipelines

### Adding an Order Pipeline

All pipelines are defined in `config/lunar/orders.php`

```php theme={null}
'pipelines' => [
    'creation' => [
        Lunar\Pipelines\Order\Creation\FillOrderFromCart::class,
        Lunar\Pipelines\Order\Creation\CreateOrderLines::class,
        Lunar\Pipelines\Order\Creation\CreateOrderAddresses::class,
        Lunar\Pipelines\Order\Creation\CreateShippingLine::class,
        Lunar\Pipelines\Order\Creation\CleanUpOrderLines::class,
        Lunar\Pipelines\Order\Creation\MapDiscountBreakdown::class,
        // ...
    ],
],
```

You can add your own pipelines to the configuration, they might look something like:

```php theme={null}
<?php

namespace App\Pipelines\Orders;

use Closure;
use Lunar\Models\Contracts\Order;

class CustomOrderPipeline
{
    public function handle(Order $order, Closure $next): mixed
    {
        // Do something to the order...

        return $next($order);
    }
}
```

```php theme={null}
'pipelines' => [
    'creation' => [
        // ...
        App\Pipelines\Orders\CustomOrderPipeline::class,
    ],   
],
```

<Tip>
  Pipelines will run from top to bottom
</Tip>
