Help me determine if two elements are the same in liquid maybe using {% assign %}

Solved
Highlighted
Explorer
96 0 4

Using Debut.

 

I'm learning how to use liquid and {% assign %} but finding it tricky. I need to compare two elements. If they are the same, I need to reveal "itworked".

The elements I'm comparing are customer.email and customer.tags[2]. Customer.tags[2] is a domain, say "https://customer-website.com". I need to determine if the domain in customer.email == customer.tags[2].

 

So, does customer@customer-website.com == customer-website.com.

Something like this:

{% if customer.email | split: "@" | last == customer.tags[2] | remove: "https://" %}it worked{% endif %}
0 Likes
Highlighted
Shopify Partner
904 194 353

This is an accepted solution.

@tesstesting 

 

Try following code:

{% assign c_email = customer.email | split: "@" | last %}
{% assign c_tag = customer.tags[2] | remove: "https://" %}
{% if c_email  != blank and c_tag != blank %}
   {% if c_email == c_tag %}
       It worked
   {% endif %}
{% endif %}

Thank you,

Tejas

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on support@hexaecommerce.com regarding any help
1 Like
Highlighted
Explorer
96 0 4

Thanks @Tejas_Nadpara 

 

Before I saw your answer I also tried this and it worked for now: 

 

{% assign test1 = customer.email | split: "@" | last %}
{% assign test2 = customer.tags[2] | remove: "https://" %}
{% if test1 == test2 %}It Worked!{% endif %}
0 Likes