Description
If one adds a coupon code starting with a hashtag '#' during the last step of the checkout process (not in the cart view itself), one gets the error message 'Request does not match any route' instead of the typical 'Coupon applied/Coupon invalid' messages.
Preconditions
- Magento 2.1.7
- PHP Version 7.0.17
- MySQL Version 5.6.34
Steps to reproduce
- Open the payment page of the checkout process, where you can add coupons (bug doesn't occur in the cart view itself)
- Add random coupon code starting with a hashtag '#'
- Click 'apply coupon'
Expected result
- standard success/error frontend messages 'coupon applied/invalid'.
Actual result
'Request does not match any route' error messages shown in frontend.
Cause
The coupon code isn't correctly encoded in
/vendor/magento/module-checkout/view/frontend/web/js/model/resource-url-manager.js,
so before the ajax call happening the following piece of code in require.js removes the complete coupon code from the request URL:
"// Remove hash character (#7531: and string promotion)
// Add protocol if not provided (#5866: IE7 issue with protocol-less urls)
// Handle falsy url in the settings object (#10093: consistency with old signature)
// We also use the url parameter if available
s.url = ( ( url || s.url || ajaxLocation ) + "" )
.replace( rhash, "" )
.replace( rprotocol, ajaxLocParts[ 1 ] + "//" );"