Anyway to auto assign a "Theme template" to a product?

52 0 32

Hi, pretty much as the title asks, is there anyway at all of auto assigning an existing product theme template to my products? 




I know we can bulk edit our products through the products section within Shopify, but what we would ideally like is a rule written so that if a product drops below "0" in inventory, the product layout alters to a second layout. I would also want us to be able to override and manually alter the theme for each product to.


I know this might no be possible without a lot of work, so even if we can use product tags or based on collection etc in anyway it would be great.


Any help would be great!

Replies 4 (4)

52 0 32

I have researched this for a long time now and still not found a possible solution, just giving the post a bump to see if anyone else could reccomend something? If anyone from Shopify could confirm if this is possible or not even?



8 1 0

You're not able to do it with the Product Templates (unless there is a supporting app), but you can look into the Liquid a bit more to help with this.


Most themes will have a product.liquid section in the product.liquid template file. You can use liquid to look to see if the product is available (has inventory or not) and alter the theme that way based on the result.


For example, you have two sections setup, one section for the product layout when it has inventory (product-in-stock.liquid), and one when it does not (product-sold-out.liquid)



{% if product.available %}
    {% section 'product-in-stock' %}
{% else %}
    {% section 'product-sold-out' %}
{% endif %}


Don't forget to smash that Like button if I've helped you out!
If you're question was answered, don't forget to Accept the Solution!

Shopify Partner
13 0 2

The killer way to do this would be with Shopify FLOW. Shopify Support Chat isn't responding today for some reason. I don't think FLOW will do it currently but that's the proper way to create this feature. Shopify could easily create a Template in Flow for this if they want to. 


Doing this with FLOW ensures it won't impact performance and will just run as a cron job in the background on a schedule etc.


Alternately If you somehow cobbled together logic in the theme it would be laborious for the server to query specific products and then apply the template as it loads. Not really an option. It needs to be a background process that results in static assignment of the template to a product based on some kind of rule (name includes, stock status, tag, etc)

Shopify Partner
1 0 0

i use javascrip to change my template via url. It not good but it is still aceptable.

if your product drop below zero,  it will add ?view="yourtemplatename" to link product to render this template