How to make alternate template in Dawn

HunkyBill
Shopify Expert
4846 60 552

In old Shopify, one can just clone product.liquid into product.alternate.liquid, and assign the alternate template to any product, and be good to go.

 

In new Shopify, this apparently is not a thing. I need two alternate product templates. So if I clone product.json, I get an empty section key and an empty order key in my alternate product.json file. That file does not apparently get added to templates, and when I browse a product, I do not get a choice of which templates to use.

Is there a helpful document on how we are supposed to function with this new JSON world of alternate templates? What I tried failed miserably, in that I created files that were apparently not saved by Shopify, and could not be used. How does one simply construct alternate product templates in Dawn? What would be a good technique?

 

At the end of the day, I want one template for ordinary products, one with a special app extension available to it, and another with a second, but different app extension available for it.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Replies 7 (7)

HunkyBill
Shopify Expert
4846 60 552

Never Mind. The solution is simple.

 

1. ignore the old concept of adding a new template using the Shopify file admin like we are used to.

 

2. Instead, click Customize Theme, and then select products, and then create a template there, and then that actually works.

 

So the fact the old method still exists and is broken for working with Dawn, screwed me for one, out of a good 30 minutes before I figured it out. Yay!

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
Eugene13
Tourist
12 0 4

hi. I'm just wondering where did you see the create template in theme customize? I can't see on my end where is that. if this is about on updating the Shopify, how? 

HunkyBill
Shopify Expert
4846 60 552

When you work on Dawn, and click customize, and then choose a resource, there is a link under the default labeled create template. I used that. 

 

My burning question now is, if I do that with code, and dupe product.json into product.alternate.json and try and save that in my templates, will it work the same as using the Admin method?

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
ThomasBorowski
Shopify Expert
803 71 239

Creating the json template in the code editor works fine, a template created that way also shows up in the template dropdown in the theme editor.

 

The theme in question does have to be published, though, otherwise you can't assign the template to a product.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
HunkyBill
Shopify Expert
4846 60 552

I beg to differ. I was working off a published theme. It had a product.json under templates. Using nothing but the built-in code editor, I selected to create a new template. Shopify asked me what to work off of. I chose product, and then gave it a new name, like test. The file was created, product.test.json in the editor. It was empty save a section object and an order key. Great. However, I was not seeing that show up in the left sidebar listing the available files. As well, there was no option to assign the template test to any products.

So maybe I am crazy, but I stand by that as an observation.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com
ThomasBorowski
Shopify Expert
803 71 239

I actually added a section and an order entry to the json, which is why it worked for me. When you create a new json template via the theme editor it adds the main-product and product-recommendations sections to the template.

 

Turns out when you create a new json template in the code editor, the file is empty and it doesn't show up in the file list. If you try saving that "empty" file you'll get an error. Only after adding at least one section and a corresponding entry in the order array can you save the file and then it'll show up in the file list.

★ Smart Upgrades, Tips and Tutorials for Shopify themes: cartpunk.com
Did my solution work? Help other Community members easily find the correct solution and apply it to their own stores by marking it as the Accepted Solution and giving it a Thumbs Up
HunkyBill
Shopify Expert
4846 60 552

The real source of frustration here is the fact that while the Theme Customization wrapper will create an alternate template, it does so by actually using the source you selected as fodder. So you achieve success with no issues. On the other hand, the edit code option I speak of, as you point out, creates a blank template by mistake, and this is the source of the issue. A blank template is near useless. I understand that someone, at some point, thought to themselves, hey, this is the way to go, but that apparently has this glaring problem I faced. Nonetheless, I am merely the messenger, and with these workarounds, it is not stopping me from getting work done. It is just a bad UX pattern laid bare.

Custom Shopify Apps built just for you! hunkybill@gmail.com http://www.resistorsoftware.com