Re: Editing .json template - linking

How can I disable default linking in a .json template?

OrganicUniverse
Excursionist
22 0 1

Hello, is it possible in anyway to disable the property of 'default' linking in a .json template.

We are creating a phone case based webshop and through our cart flow you need to choose 'phone model' and afterwards 'case color' - to archive a fluid flow we have created a page for each iphone model (11 pages) which uses the same template, since it easier to edited them all this way - but each page have their owen product variant.

I am not able to edit the linking property so its specific for each page, since the linking default based.

Example:

On this page:  https://officalorganicuniverse.myshopify.com/pages/iphone-12-pro - i need to link to our variant id's for 12 pro in green, pink, black etc.

And on this page: https://officalorganicuniverse.myshopify.com/pages/iphone-12-pro-max - i need to link to our variant id's for 12 pro max in green, pink, black etc.

Since both pages are using the same template, i cant assign a unique link.

I hope this makes sense and you guys have a solution.
As far as I know the only work around would be to create a template for each page... And then we loose the ability to change all 15 pages if we want to change the looks or anything.

Replies 4 (4)

Prabhat
Shopify Partner
84 8 29

Make use of page metafields. Then use that to pull the products.

You may have to update the template such that it pull data from metafield instead of from the customizer. 

Solution Expert
- Did I solved your issue? Like & Mark As Solution to help the community.

Checkout Rules and Content - Checkout Pro
OrganicUniverse
Excursionist
22 0 1

Sorry i am a newbie to coding. Could use please describe it mere in depth, since I am no expert in .json

Prabhat
Shopify Partner
84 8 29

Hi @OrganicUniverse 

Well Shopify have something called metafield which can store any extra values and can be retrieved where required. Hence we can make use of it. Generally a free app such as Metafield Guru will help you to get started on page metafield.

A metafield can be then access like this 

{{ page.metafields.namespace.key }}

This value you can use in the code to render different aspect even having same template.
So suppose you want to get a product you can do something like 

{{ all_products[page.metafields.namespace.key].title }}

You can access all the value of the product 

page.metafields.namespace.key contains the product handle in the above example.

Solution Expert
- Did I solved your issue? Like & Mark As Solution to help the community.

Checkout Rules and Content - Checkout Pro
OrganicUniverse
Excursionist
22 0 1

thaks will give it a try!