<p>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.</p>

<p>So in this case I set up a route for </p>

<p><code>/type/*/*</code> -> <code>shop/variant</code></p>

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

CC BY-SA 4.0
2018-12-13T13:53:09.010Z
2018-12-13T13:53:09.010Z
foamcow
<p>Is it possible to use a wildcard when specifying the template path for a Commerce 2 product type?</p>

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

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

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

<templating><plugin-craftcommerce2><products>
Including a variant segment in product type template route in Commerce 2
# Including a variant segment in product type template route in Commerce 2

(Asked by: username_0 on 2018-12-13)

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.

**Tags:** templating, plugin-craftcommerce2, products

---

## 1 answers

### Answer by username_0 on 2018-12-13. Score: 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.


---

