PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, July 1, 2022

[FIXED] How to fetch unique value in liquid file

 July 01, 2022     shopify     No comments   

Issue

here is my code i tried to fetch only unique value from items variable but I got all value can someone please help to solve this

       {% capture items %}
          {% for tag in product.tags %}              
          {%if tag contains 'pair'%} 
          {% assign tag_split = tag  |  remove_first: 'pair::' | split: "::" %}
          {% assign color = tag_split[0]  %} 
             {{color}}
          {% endif %}
          {% endfor %}              
       {% endcapture %}

          {% assign my_array = items | split: ", " %}

          <p>{{ my_array | uniq }} </p>


         
         

Solution

This filter should help you to keep only one elem per value: https://shopify.github.io/liquid/filters/uniq/



Answered By - Alice Girard
Answer Checked By - Clifford M. (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing