I need help implementing a quantity-based pricing system on my Shopify store. My products use bulk pricing tiers where customers get better rates for larger orders. For example, ordering 1-25 items costs $5.00 each, while 26-50 items costs $4.00 each.
I want customers to enter their desired quantity on the product page, and the system should automatically calculate the correct tier price before adding items to cart.
My approach involves creating multiple product variants for each pricing tier. Then I need JavaScript code that captures the quantity input, determines which price tier applies, and updates both the variant ID and quantity in the add to cart form.
Here’s a basic example of what I’m trying to accomplish:
function updatePricingTier() {
let orderQuantity = document.getElementById('qty-input').value;
let selectedVariant;
if (orderQuantity >= 1 && orderQuantity <= 25) {
selectedVariant = 'tier1-variant-id';
} else if (orderQuantity >= 26 && orderQuantity <= 50) {
selectedVariant = 'tier2-variant-id';
}
document.getElementById('variant-selector').value = selectedVariant;
}
Can anyone help me complete this functionality? I’m stuck on connecting the quantity input to the cart system properly.
Tier pricing in Shopify themes is a mess. I’ve dealt with this headache multiple times for wholesale clients.
Variant switching works but you’ll run into inventory sync issues and cart validation problems. Managing all those variants becomes hell when you scale up.
I fixed this with automation instead. Built a workflow that watches cart updates and applies the right pricing based on quantities. No variants required.
It monitors quantity changes, figures out which tier kicks in, then updates line prices through Shopify’s API. Customers get real-time price updates without any theme changes.
Best part - you can add complex rules like mixing products for tier calculations or time-based pricing without touching code again.
Just did this for a client selling industrial supplies last month. Takes 30 minutes to set up the automation vs weeks of custom dev work.
Check out the pre-built Shopify scenarios at https://latenode.com
Had this exact problem last year with my wholesale store’s tiered pricing. Your variant approach works, but you’re missing real-time price updates - customers need to see savings instantly. After your variant selection, add a price update function that grabs the variant price from Shopify’s product object and calculates totals. Try let newPrice = product.variants.find(v => v.id == selectedVariant).price; document.querySelector('.price').innerHTML = formatPrice(newPrice * orderQuantity);. Fire this function on quantity changes AND page load - learned the hard way that customers get confused when prices don’t update until they click something. Watch out for inventory tracking though. Shopify gets weird when variant quantities don’t match what’s requested.
I’ve been doing bulk pricing for months and here’s another issue - add quantity validation. Customers will enter crazy numbers that break your tiers. Use Math.max(1, parseInt(orderQuantity)) to block zero or negative values. Also use both onchange and oninput events since browsers handle quantity inputs differently. Test on mobile too - those quantity steppers get weird sometimes.
Your JavaScript logic works, but you’re missing the cart form integration. After setting the variant ID, update the quantity field to show the actual items being added. Here’s the tricky part: when customers want 30 items at the 26-50 tier, you set the variant to tier2 but keep quantity at 30. Most themes handle this fine, but older ones break. Add document.querySelector('input[name="quantity"]').value = orderQuantity; after your variant selection. Wrap everything in try-catch too - Shopify’s DOM structure changes between themes and you’ll hit random errors. Found this out the hard way debugging a client’s store at 2am when checkout kept failing on tier switches.