How to output product title of all products with specific tag in customers/account

I’m using Debut.

On my customers/account, I need to output a list of product titles of all products containing a specific tag. This specific tag needs to be referenced by using “customer.tags.first”. Is this possible to achieve?

I’m thinking something like this, but it doesn’t work:

{% for product in tags[customer.tags.first].products %}
{{ product.title }}
{% endfor %}

I think what you want to achieve is something like this:

  1. Only output product titles on the account page if the “customer tag” contains a specific tag like for example “wholesaler” tag.

  2. When the customer tag exists (true), then you want to output product titles and stuff if the product contains a specific tag like “new”.

Your solution is a bit more complex i think.

Maybe try this approach.

  1. check if the specific customer tag exists

(ref: https://help.shopify.com/en/themes/liquid/objects/customer#customer-tags)

({% for tag in customer.tags %}
  {% if tag == 'myTag' %}

  {% endif %}
{% endfor %}
  1. get the products object by getting a specific collection using its handle something like:

(ref: https://help.shopify.com/en/themes/liquid/objects/collection#collection-products )

{% assign collection = collections[my-collection-handle] %}
  
  {% paginate collection.products by 99 %}
  {% assign products = collection.products %}

  {% if collection.products.size > 0 %}

  {% for product in products %}
    {% for tag in product.tags %}
      {% if product.tag == 'limited_edition' %}
        <p>{{ product.title }}</p>
      {% endif %}
    {% endfor %}
  {% endfor %}

  {% endif %}

  {% endpaginate %}

so all put together this could look like this (please make a backup of your theme or edit/try this on a demo store *not tested):

{% for tag in customer.tags %}
  {% if tag == 'myTag' %}

  {% assign collection = collections[my-collection-handle] %}
  
  {% paginate collection.products by 99 %}
  {% assign products = collection.products %}

  {% if collection.products.size > 0 %}

  {% for product in products %}
    {% for tag in product.tags %}
      {% if product.tag == 'limited_edition' %}
        <p>{{ product.title }}</p>
      {% endif %}
    {% endfor %}
  {% endfor %}

  {% endif %}

  {% endpaginate %}
    
  {% endif %}
{% endfor %}

… i hope this gets you closer to what you want.

If you want to call product title in any of the page please write the code on particular product title place is {{product.title}}