Skip to main content
4 of 4
added 71 characters in body

I figured out a solution that works for me. In the beforeDispatch() method of my FrontControllerInterface plugin, I have the following block of code:

$requestPath = $this->request->getPathInfo();

// If a coupon code was included in the URL, fix the URL
// after extracting it so that we can continue to route normally
if (preg_match("#/discount/([^/]+?)/*$#", $requestPath, $matches)) {

    $coupon = $matches[1];
    $realPath = str_replace($matches[0], '', $requestPath);

    if (!$realPath) {
        $realPath = '/';
    }

    $this->request->setPathInfo($realPath);
}

This does exactly what I need. Hope it can also help someone else in the future.

EDIT: The plugin I was writing can be found here: https://github.com/crankycyclops/DiscountCodeUrl It's a free and open source means to automatically apply coupon codes via the URL. Hope someone finds it useful :)