What's your biggest current challenge? Have your say in Community Polls along the right column.

If else statements not working as expected in Custom Liquid Code

If else statements not working as expected in Custom Liquid Code

Zainalee
New Member
4 0 0

{% if product.handle == "red-light-oil-massager" %}
Show text ABC{% elsif product.handle == "purewater-derma-showerhead" %}show text xyz{% endif %}

I am using static text directly in custom liquid, it shows accordingly in admin panel when I am editing, but when I save and check live, it did not work, it keep showing "red-light-oil-massager" content on other product handle,

I have another similar case:-
I have slide groups, I am trying to show different slides, according to product Id's, same error, even after deleting all content of 1 product slide, it still appearing on other product,

Like 
{% if product.id == 12345 %}
show slides from 1-2-3
 {%elsif product.id == 6789 %}
show slides from 4-5-6
{% endif %}

now after deleting complete slides and the text of slides 1-2-3,
The live site still showing 1-2-3 slides and text of slide on product ID 6789(while in admin panel it showing correct)
I have cleared the cache, but still not resolving, can anyone help me with this?

Note:- I am not using custom data, is that the problem?

Replies 4 (4)

Zainalee
New Member
4 0 0

This is admin view in admin panel,
admin-view.PNG

and this is what appears on live, even I have removed all these slides and text :()
live-view.PNG

namphan
Shopify Partner
2067 273 306

Hi @Zainalee,

This will need to be checked in more detail, can I send you a collaborator invite? it will help me debug things better

Coffee tips fuels my dedication.
Shopify Development Service
PageFly Page Builder Optimize your Shopify store (Free plan available)
Need help with your store? namphan992@gmail.com

tim
Shopify Partner
3911 394 1435

If you have multiple markets, make sure that when you're editing in Customizer it happens under proper market.

Also, make sure that current product variable is actually called product where you apply your "Custom liquid".

 

Otherwise, if you can share actual liquid code and link to a page where it does not work as you wish it would be easier to suggest something.

 

If my post is helpful, consider liking it -- it will help others with similar problem to find a solution.
I can be reached via e-mail tairli@yahoo.com
Zainalee
New Member
4 0 0

I have no other active markets yet!