How can I create a tag array using raw data in product grids?

Hey techies hope all are well,

I have created a tags array for all the product grids using

{% capture tags %}{% if product.tags.size > 0 %}{% for tag in product.tags %}{{ tag | upcase }}{% unless forloop.first %},{% endunless %}{% endfor %}{% endif %}{% endcapture %}

but now i want the same for the recently viewed section which is using raw data.

so i have added this code :

{% raw %}{{if tags}}{{each tags}}${tag}{{if $index != 0}},{{/if}}{{/each}}{{/if}}{% endraw %}

but no luck, can someone please guide me with the correct syntax to make a tag array using raw data.

Thanks and Regards.

Hi @Savior-Info

If you wish to generate a tags array in the recently viewed section using raw data, consider implementing the code provided below:

{% raw %}
  {{#each product.tags}}
    {{@key}}: {{this}}
    {{#unless @last}},{{/unless}}
  {{/each}}
{% endraw %}

@okur90

Thanks for the help.

I applied your code but when i added the recently viewed section disappeared.

here i have attached the screenshot for your reference. https://prnt.sc/EyZCK4GB2lMF

Please check and help me

Thanks

@Savior-Info

{% raw %}
  {{#each product.tags}}
    {{this}}{{#unless @last}},{{/unless}}
  {{/each}}
{% endraw %}

I can’t see the screenshot. If the above code doesn’t work, please provide more context or code snippets from your template, so I can better understand the issue and help you resolve it

@okur90

I have DM you can i share the code there?