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.


Revision #1
Created 2026-09-22 06:51:01 UTC by Ethan Payne
Updated 2026-09-22 06:57:42 UTC by Ethan Payne