2

Is it possible to use a wildcard when specifying the template path for a Commerce 2 product type?

I want to format my URLs as /type/product/variant
Where 'variant' could be a custom field applied to the product variant.

In the settings for my product type I've tried a few things, including setting the "Category URI Format" to variations of /type/{slug}/{variant.customField} all to no avail. The template isn't found as soon as I include that third segment to the URL.

I feel this should be possible to do with Routes but having much the same problem.

1 Answer 1

1

Have figured out that instead of setting a template path in my product type I can leave that blank and use a custom route instead.

So in this case I set up a route for

/type/*/* -> shop/variant

It means I need to fetch the product entry manually in the template but that's no problem and it seems to be working.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.