Shopify B2B Quantity Rules Not Showing in Liquid? Here's the Fix!
Hey everyone! As a Shopify migration expert and someone who spends a lot of time digging through the community forums, I often come across really interesting and sometimes frustrating issues that store owners and developers are battling. Recently, a thread caught my eye that really highlights a specific pain point for anyone setting up B2B stores on Shopify: getting those custom quantity rules to actually show up correctly in your theme's Liquid.
It's a classic head-scratcher, where everything seems set up perfectly on the backend, but the frontend just isn't cooperating. Let's dive into what we learned from our community discussion and how to tackle this.
The B2B Quantity Rule Mystery: Liquid vs. Cart API
Our community member, bencar02, kicked off the discussion with a familiar scenario. They were meticulously configuring a development store's B2B catalog, setting up specific quantity rules for products — things like a minimum purchase of 3 units, or increments of 3, with no maximum. Sounds straightforward, right?
The tricky part was, while the Cart API was returning the correct responses (meaning it wouldn't let them add less than 3, or increment incorrectly), the theme Liquid was stubbornly defaulting. Specifically, product.selected_or_first_available_variant.quantity_rule within the Liquid template was always showing a minimum of 1 and increments of 1, completely ignoring the B2B catalog rules. This is what it looked like:

As bencar02 pointed out, the documentation suggests that if rules are configured via a B2B catalog, Liquid should use those values instead. But alas, it wasn't happening, leading them to consider a custom JavaScript workaround.
The Community's Insight: It's a Known Issue!
This is where the power of the community really shines! Another helpful member, Moeed, jumped in with some crucial information. They confirmed that this exact situation — where the Cart API returns correct catalog rules, but variant.quantity_rule in Liquid defaults — is a documented issue on the Shopify Developer Community forums. Phew! It's not just you; it's a Shopify-side rendering bug.
This is great news in a way, because it means your B2B catalog setup is likely just fine. The problem lies in how Liquid is (or isn't) receiving that data from the backend.
First Things First: Rule Out the Basics
Before jumping to the conclusion that you've hit the bug, Moeed wisely suggested a few checks. These are always good practice when things aren't quite working as expected with B2B features, as the context needs to be just right:
1. Confirm Your B2B Context
For B2B quantity rules to apply, the customer needs to be fully in a B2B session. This means:
- The customer is logged in.
- They are tied to a company location.
- That company location has the correct B2B catalog with the rules assigned.
How to check: Drop these Liquid snippets into your template temporarily to verify:
{{ customer.b2b? }}
{{ customer.current_location.id }}
Both should return 'truthy' values (true for customer.b2b? and an ID for customer.current_location.id).
2. Check Your Theme Version
Shopify's B2B features are constantly evolving, and sometimes specific Liquid functionality has version requirements. For B2B quantity rules to work in Liquid (when they're not bugged!), you typically need free themes version 8.0.0 or higher.
How to check: Go to your Shopify admin, navigate to 'Online Store' > 'Themes', and check the version of your active theme. If it's older, consider updating to the latest version (always test theme updates on a duplicate first!).
3. Test Against Your Published Theme
This is a subtle but important one! The bug itself can manifest differently depending on your development environment. The Shopify Developer forum thread indicates that the issue might surface differently between a CLI preview environment and your actual published theme.
How to check: Always test your B2B quantity rules on your live, published theme (or a theme in preview mode that's not a local CLI preview) to get the most accurate picture.
The Solution: Embracing JavaScript for Robustness
If you've gone through all those checks and confirmed everything is correctly configured, then — bingo! — you're hitting the documented bug. So, what's the best path forward?
Moeed's advice here is spot on: the JavaScript workaround bencar02 mentioned isn't really a 'hack' in this scenario. In fact, Shopify's own documentation often suggests using JavaScript to fetch updated rules, especially on variant changes. This approach ensures you're always pulling the most accurate, real-time data.
Implementing the JavaScript Workaround:
The core idea is to rely on API endpoints that *are* consistently returning the correct B2B quantity rules. You can fetch this data via:
-
The Variant API Endpoint: You can make an AJAX request to
/variants/{id}.js. This endpoint provides detailed information about a specific variant, and crucially, will return the correct B2B quantity rules within the current B2B session context.Example (conceptual JavaScript):
fetch('/variants/' + variantId + '.js') .then(resp> response.json()) .then(variantData => { // Access quantity rules from variantData // e.g., variantData.quantity_rule.min, variantData.quantity_rule.increment // Update your quantity input fields accordingly }) .catch(error => console.error('Error fetching variant data:', error)); - The Cart API: While more typically used for cart operations, the Cart API also understands the B2B session and can provide correct quantity rule validation. You might use this in conjunction with your add-to-cart logic to ensure rules are enforced, even if the UI isn't perfectly reflecting them initially.
The key is to trust the values returned by these API calls over what variant.quantity_rule in Liquid might be telling you directly on page load. You'll want to implement this JavaScript to:
- Fetch the correct quantity rules when the page loads (especially if a specific variant is pre-selected).
- Update the quantity input fields (min, max, step attributes) dynamically whenever a customer selects a different variant.
This ensures your customers see and interact with the correct quantity rules, providing a seamless B2B experience despite the underlying Liquid inconsistency.
What's Next?
Moeed also suggested, and I wholeheartedly agree, that if you're hitting this bug, it's worth posting your findings on community.shopify.dev. This is where Shopify's own developers actively engage, and reporting these issues helps them prioritize fixes and get traction. The more voices, the better!
It's always a learning curve with e-commerce platforms, especially when dealing with advanced features like B2B. While it's frustrating to run into these kinds of rendering inconsistencies, knowing it's a documented issue and having a solid workaround from the community makes all the difference. Keep an eye on those developer forums for updates, and in the meantime, leverage that robust JavaScript to keep your B2B store running smoothly!