Hello,
first of all I’m new to shopify and liquid.
I modified code in the card-product.liquid file (Dawn Theme) line 127.
…modified theme code
The modification is doing what I expect. Modifying the existing badge for “Sale” and add a aditional badge for “2.nd hand”
Now I would like to “outsource” the modified theme code in a seperate custom-liquid-file and call it with
{% render ‘custom-liquid-file’ %}
I copied everything including the div tags
…modified theme code
And pasted it in a custom liquid file (OurCompanyName-CustomBadges.liquid)
instate of the original code I inserted {% render OurCompanyName-CustomBadges %}
As expected it is not working.
I assume the objects card_product and settings don’t exist in OurCompanyName-CustomBadges.liquid
I tried {% render OurCompanyName-CustomBadges, card_product:card_product, settings:settings %}
But I have nothing written in OurCompanyName-CustomBadges.liquid to receive this object variables.
As expected it doesn’t work.
I tried {%- include card_product, settings -%} in the first line of OurCompanyName-CustomBadges.liquid without success.
I have no clue where I can find documentation on how this works and spend hours to research it.
It seems a extrem simple beginner question, so simple that nobody explained it somewhere.
I would realy appreciate if somebody could help me out on this.
The purpose of my approach here is to transfer custom code clean and easy to new versions of the theme.
Each custom code would have its on file beginning with companyname-…
And in the theme liquid files there would be only one line with {% render …}
Our custom liquid file would have at the beginning a comment section describing where the {% render …} needs to be paste after a theme update.
This way we only have to search for companyname in the current version and transfer all this files to the new version of the theme. Then copy the line in the comment section at the top inside the file and replace theme code as described also in this comment section.