I have a button on a product page that I would like to link to a “Request Quote” page, passing some of the product details e.g. a URL like “/request-quote?product=Foo%20Bar&sku=1234”. I can easily add dynamic data when constructing the URL, but I need to (or should) URL encode the parameters. Is there a built-in filter I can use to achieve this, or how best to do it?
You’ll want to make sure any dynamic values get properly encoded so special characters don’t break the link. In most setups you can just use something like encodeURIComponent() (in JavaScript) to handle it, or the built-in escaping/filter functions if your framework provides them. That way your parameters like product names with spaces or symbols will stay safe in the URL.