# What is the order item builder?

The order item builder is run whenever a cart item is transformed into an order item. It builds the order item data from the cart item.

For example, you can add a custom attribute to the order item:

```php
\Aero\Cart\OrderItemBuilder::extend(function (\Aero\Cart\OrderItemBuilder $builder, \Closure $next) {
    $cartItem = $builder->item();

    $builder->setAttributes([
        'acme' => $cartItem->meta->get('acme'),
    ]);

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

---

### Parameters

<table border="1" id="bkmrk-parameter-type-descr" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col><col style="width: 33.3731%;"></col></colgroup><tbody><tr><td>**Parameter**</td><td>**Type**</td><td>**Description**</td></tr><tr><td>`$builder`</td><td>`\Aero\Cart\OrderItemBuilder`</td><td>The order item builder.</td></tr><tr><td>`$next`</td><td>`\Closure`</td><td>The next step in the order item builder.</td></tr></tbody></table>

### Methods

<table border="1" id="bkmrk-method-description-i" style="border-collapse: collapse; width: 100%;"><colgroup><col style="width: 50.0596%;"></col><col style="width: 50.0596%;"></col></colgroup><tbody><tr><td>**Method**</td><td>**Description**</td></tr><tr><td>`item()`</td><td>Returns the cart item being transformed.</td></tr><tr><td>`order()`</td><td>Returns the order that the order item will be added to once transformed.</td></tr><tr><td>`setAttribute(string $key, $value)`  
</td><td>Sets an attribute to be added to the order item.</td></tr><tr><td>`setAttributes(array $attributes)`  
</td><td>Sets attributes to be added to the order item (merges them with existing attributes).</td></tr><tr><td>`getAttribute(string $key)`  
</td><td>Returns the attribute corresponding to `$key` or `null` if it doesn't exist

</td></tr><tr><td>`getAttributes()`  
</td><td>Returns the array of attributes to be set on the order item

</td></tr></tbody></table>