Liquid, JavaScript, themes, sales channels
To continue receiving payouts, you need to secure your account by turning on two-step authentication. If two-step authentication is not turned on your payouts will be paused. Learn more
I want to hide the buy button when I see multiple vendors for an item in my cart.
I would like to know how to do the conditional branching.
Is there a good way to do this?
Solved! Go to the solution
This is an accepted solution.
Hi @さんつ,
Please add code like this:
{%- assign check = 1 -%}
{%- assign vendor = '' -%}
{%- for item in cart.items -%}
{%- if vendor != item.vendor -%}
{%- assign vendors = item.vendor -%}
{%- assign check = check | plus : 1 -%}
{%- endif -%}
{%- endfor -%}
{%- if check > 2 -%}
<!-- hidden buy button -->
{%- endif -%}
Hope it helps!
If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck
This is an accepted solution.
Hi @さんつ,
Please add code like this:
{%- assign check = 1 -%}
{%- assign vendor = '' -%}
{%- for item in cart.items -%}
{%- if vendor != item.vendor -%}
{%- assign vendors = item.vendor -%}
{%- assign check = check | plus : 1 -%}
{%- endif -%}
{%- endfor -%}
{%- if check > 2 -%}
<!-- hidden buy button -->
{%- endif -%}
Hope it helps!
If my answer can help you solve your issue, please mark it as a solution. Thank you and good luck
Thanks for your reply!
You have helped me to solve my problem.
I also learned a lot about how to write this kind of code using liquid.
Thank you very much for your help.
Learn these 5 things I had to learn the hard way with starting and running my own business
By Kitana Jan 27, 2023Would you love to unleash the unbridled power of the Google Shopping Channel into your sho...
By Gabe Jan 6, 2023How can you turn a hobby into a career? That’s what Emmanuel did while working as a wa...
By Skye Dec 30, 2022