I want to hide the buy button when I see multiple vendors for an item in my cart.

Solved
さんつ
Shopify Partner
39 11 50

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
Trailblazer
291 72 72

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
Trailblazer
291 72 72

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

さんつ
Shopify Partner
39 11 50

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.