1

我正在尝试获取 name: 和 value: 的值,具体取决于用户的国家代码。所以示例用户位置是“DE”,它应该输出:

TRS_TITLE_DE

哈利波特密室 I 硬背壳兼容 Apple iPhone 12

这是数组:

{
          "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"
       },

这是我尝试过的:

{{#if settings.country_code "==" "DE"}}
  <h1>
    {{itemAt product.custom_fields 2}}    
  </h1>      
{{else}}
    <h1>It's not there</h1>
{{/if}}
4

1 回答 1

1

假设您已将国家/地区代码完全按照设置中显示的方式放入自定义字段中,则以下内容应该可以解决问题:

{{#each product.custom_fields}}
    {{#contains name ../settings.country_code}}
        <h1>{{{value}}}</h1>
    {{/contains}}
{{/each}}
于 2021-06-14T14:09:03.190 回答