The cart system can be extended with custom pipelines and modifiers to add business logic.
Overview
Carts are a central part of any e-commerce storefront. The cart system is designed to be easily extended, allowing any custom logic to be added throughout a cart’s lifetime.
Pipelines
Adding a Cart Pipeline
All pipelines are defined in config/lunar/cart.php
You can add your own pipelines to the configuration, they might look something like:
Pipelines will run from top to bottom
Actions
During the lifecycle of a cart, various actions are taken. While generally what Lunar provides will be fine for most storefronts, there are times where something slightly different may be needed. For this reason, all actions are configurable and can be swapped out as needed.
Actions are defined in config/lunar/cart.php and if you need to replace an action, check the class of the action you want to change to see what it is expecting.
Action validation
You may wish to provide some validation against actions before they run. Your own validation may look something like:
You can then register this class against the corresponding action in config/lunar/cart.php:
If validation fails, a Lunar\Exceptions\Carts\CartException will be thrown. Errors can be accessed in the same way as Laravel’s own validation responses.