Looping Through Tagged Products To Show Them In The Additional Detail Box In The Shopify Backend

- 1 answer

I'm trying to loop through tagged products to show in the the additional detail box in the backend, but I only get one product. Here is the case, I have some products tagged with warranty, so I'm implementing a condition stating that if the customers cart has - say - 3 products (2 of those tagged with warranty and the other one is not), then I would like to bring the names of the ones tagged with warranty and display them in the additional detail box in the backend.

The issue I'm facing is that I get only one product name even if the customer's order included 3 different products with the same warranty tag.

This is the code I'm implementing:

 {% for itemTwo in cart.items %}

<p class="cart-attribute__field">
      {% for tag in itemTwo.product.tags %}
      {% if tag contains 'warranty' %}

  <input id="products-registered" type="text" name="attributes[products registered]" value="{{ itemTwo.product.title }}">

        {% endif %}
        {% endfor %}


        {% endfor %}

Thanks for your help



I found a way around. I had to loop over the value in the input field. That solved out the issue.