How can I intercept discount code handling?
You can use the addCodeHandler() method to add a discount handler to the cart, it will run the provided callback whenever a code is added to the cart:
\Aero\Cart\Cart::addCodeHandler(function (\Aero\Cart\Cart $cart, string $code) {
if ($code === 'acme') {
// Do external stuff...
return true;
}
return false;
});
Return true to handle the code yourself. Return false to let the Cart handle it normally.