I currently have a Craft Commerce site where the product url is setup like this:


So this gives an example url of category1/category2/category3/my-product

This all works fine. What I'd like to do is add an optional segment onto the end of this url, so for example:


I'd like the current urls to continue working, but if you add the extra optional-thing segment to the url you also get the same product.

Ultimately this is so that I can preselect a variant in a carousel on the product detail page.

I've tried doing this with routes, but so far I've been unsuccessful. Is this the right approach or is there a better, more Commerce specific way?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.