How do I extend pipelines?

The payload data can be altered using the extend() method. This is typically done from within a Service Provider:

For example, if a module needs to add an option to items to flag them as requiring gift wrap, the CartItemBuilder pipeline class should be extended in the module's ServiceProvider as shown below:

<?php

namespace Aerocargo\Acme;

use Aero\Cart\CartItemOption;
use Aero\Common\Providers\ModuleServiceProvider;
use Aero\Store\Pipelines\CartItemBuilder;

class ServiceProvider extends ModuleServiceProvider
{
    public function setup() 
    {
        CartItemBuilder::extend(function ($item) {
            if (request()->has('gift_wrap')) {
                $option = CartItemOption::create('Gift wrap');

                $item->addOption($option);
            }
        });
    }
}

 

 


Revision #1
Created 2026-09-23 12:56:51 UTC by Ethan Payne
Updated 2026-09-23 12:59:27 UTC by Ethan Payne