FROM CACHE - en_header

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.

 

 

Reply 1 (1)
LitExtension
Shopify Partner
4671 952 977

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
Check out our Shopify migration app to migrate your online store to Shopify