I'm trying to get values of name: and value: depending on the user's country code. So example users location is 'DE' it should output:
TRS_TITLE_DE
Harry Potter Chamber Of Secrets I Hard Back Case Compatible With Apple iPhone 12
This is the array:
{
"id":3,
"name":"TRS_TITLE_DE",
"value":"Harry Potter Chamber Of Secrets I Hard Back Case Compatible With Apple iPhone 12"
},
{
"id":4,
"name":"TRS_TITLE_FR",
"value":"Harry Potter Chamber Of Secrets I Hard Back Case Compatible With Apple iPhone 12"
},
{
"id":5,
"name":"TRS_TITLE_IT",
"value":"Harry Potter Chamber Of Secrets I Hard Back Case Compatible With Apple iPhone 12"
},
{
"id":6,
"name":"TRS_TITLE_US",
"value":"Harry Potter Chamber Of Secrets I Hard Back Case Compatible With Apple iPhone 12"
},
This is what I have tried:
{{#if settings.country_code "==" "DE"}}
<h1>
{{itemAt product.custom_fields 2}}
</h1>
{{else}}
<h1>It's not there</h1>
{{/if}}
Assuming you have put the country codes into the custom fields exactly as they would display in the settings, the following should do the trick:
{{#each product.custom_fields}}
{{#contains name ../settings.country_code}}
<h1>{{{value}}}</h1>
{{/contains}}
{{/each}}