Controlling the logic of the checkout if there is more than products from one collection

SquareMarket
Tourist
7 0 0

I have multiple vendors operating from my site. Each vendor is a 'collection'. I don't want to allow a user to check-out if there is products from more than one collection.  If that is the case, then i want to disable the checkout button.

 

 

0 Likes
LitExtension
Shopify Partner
1191 150 212

Hi @SquareMarket

You can use if code to check:

{%- assign check = 0 -%}

{%- assign checkCollection = '' -%}

{%- for item in cart.items -%}

        {%- if checkCollection != item.product.collections[0].handle -%}

          {%- assign check = check | plus: 1 -%}

          {%- assign checkCollection = item.product.collections[0].handle -%}

        {%- endif -%}

{%- endfor -%}

{%- if check > 1 -%}

// show button checkout

{%- endif -%}

LitExtension - Shopping Cart Migration Expert
If our answer is helpful then please accept as solution!
Are you looking for a solution to migrate to Shopify? Contact us for further assistance.
Try our FREE DEMO now!
0 Likes