From 6867a6fe9be6db951683f72ae3068566bec5c8ba Mon Sep 17 00:00:00 2001 From: Elisa Dela Cruz Date: Thu, 5 Mar 2026 18:40:51 +0800 Subject: [PATCH 1/3] feat: add cart validation logic and error banner --- sections/main-cart.liquid | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/sections/main-cart.liquid b/sections/main-cart.liquid index a3f228ade..4505ae970 100644 --- a/sections/main-cart.liquid +++ b/sections/main-cart.liquid @@ -1,3 +1,21 @@ +{% liquid + # Code for Detecting B2B Customer + assign is_b2b = false + if customer and customer.tags contains 'b2b' + assign is_b2b = true + endif + + # Metafield with fallback + assign moq = shop.metafields.custom.b2b_moq.value | default: 6 | plus: 0 + assign cart_qty = cart.item_count + + # Logic + assign blocks_checkout = false + if is_b2b and cart_qty < moq + assign blocks_checkout = true + endif +%} + {% capture cart_page_more_blocks_content %}
{%- content_for 'blocks' -%} @@ -47,6 +65,14 @@ {%- unless cart.empty? -%}
+ + {%- comment -%} B2B MOQ Error Banner Injected Here {%- endcomment -%} + {% if blocks_checkout %} +
+ Minimum Order Requirement: As a B2B customer, you must purchase at least {{ moq }} items. You currently have {{ cart_qty }}. +
+ {% endif %} + {%- content_for 'block', id: 'cart-page-summary', type: '_cart-summary' -%}
{%- endunless -%} @@ -235,4 +261,4 @@ } ] } -{% endschema %} +{% endschema %} \ No newline at end of file From 74d3ada84d6bef470596f53873e4ea198698f6a3 Mon Sep 17 00:00:00 2001 From: Elisa Dela Cruz Date: Thu, 5 Mar 2026 18:41:20 +0800 Subject: [PATCH 2/3] fix: prevent checkout when MOQ not met --- snippets/cart-summary.liquid | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/snippets/cart-summary.liquid b/snippets/cart-summary.liquid index c55a5d9a1..6d1dbbb27 100644 --- a/snippets/cart-summary.liquid +++ b/snippets/cart-summary.liquid @@ -5,6 +5,20 @@ @param {string} [section_id] - The section ID for cart discount component. {%- enddoc -%} +{% liquid + assign is_b2b = false + if customer.tags contains 'b2b' + assign is_b2b = true + endif + + assign b2b_moq = shop.metafields.custom.b2b_moq.value | default: 6 | plus: 0 + assign moq_not_met = false + + if is_b2b and cart.item_count < b2b_moq + assign moq_not_met = true + endif +%} +
{% # We need to keep this node in place to allow morphing to work properly # %}
@@ -254,12 +268,21 @@
+ {% if moq_not_met %} + + {% endif %} + - {% if additional_checkout_buttons and settings.show_accelerated_checkout_buttons %} + {% if additional_checkout_buttons and settings.show_accelerated_checkout_buttons and moq_not_met == false %}