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.

Solved
さんつ
Shopify Partner
43 14 52

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?

Accepted Solution (1)

Accepted Solutions
LitCommerce
Astronaut
2819 668 651

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

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!

View solution in original post

Replies 2 (2)
LitCommerce
Astronaut
2819 668 651

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

LitCommerce - The Most Simple & Affordable Multi-channel Selling Tool.
Effortlessly sell on biggest marketplaces like Amazon, Etsy, eBay, Facebook etc with bulk listing tool, real-time sync & smart order management. Use LitCommerce free for 1-year now!
さんつ
Shopify Partner
43 14 52

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.