Mastering Shopify Discounts: Solving Unit-Based Product Rounding & Display Challenges
Hey fellow store owners! You know, running an online business means constantly fine-tuning things, and sometimes, even something as seemingly simple as a discount code can throw a wrench in your plans. I recently followed a fascinating discussion in the Shopify community that perfectly illustrates this, and it’s a problem many of you selling products by specific units—like fabric by the centimeter or wire by the meter—might encounter.
Our community member, MariaOthersew, who runs a fabric store, brought up a head-scratcher: her 10% coupon discount wasn't calculating correctly. Her products are priced per centimeter (e.g., €0.15/cm), and when a customer bought, say, 80cm, the discount ended up being way off. Instead of the expected €1.36 (10% of €13.60), Shopify was applying a meager €0.80. What was going on?
Understanding Shopify's Discount Quirks: Unit Price vs. Line Total
This issue boils down to how Shopify’s native discount types handle rounding, especially with low unit prices. As Maria and other experts in the thread, like Ploqo, pointed out, the core problem is that Shopify was calculating the discount on the unit price and then rounding it, rather than on the line subtotal. Let's break it down:
- If a product is €0.15/cm and you offer 10% off, Shopify’s "Amount off product" type calculates 10% of €0.15, which is €0.015. Since currency can't go below a cent, Shopify typically rounds this down to €0.01.
- Then, it multiplies that rounded €0.01 discount by the quantity (e.g., 80cm), resulting in a total discount of only €0.80.
That's a huge difference from the correct €1.36! Ploqo did an excellent job demonstrating this with screenshots, showing how the "Amount off product" type results in a marked-down unit price, while "Amount off order" keeps the unit price intact and discounts the subtotal.



The challenge is that while an "Amount off order" discount calculates correctly on the subtotal, native Shopify discounts don't allow you to target specific products or collections within that order. Maria needed a discount code like WELCOME10 to apply only to certain fabric types, not the entire cart.
The Solutions: Getting Your Discounts Right
So, how do you get the best of both worlds: accurate subtotal calculation and targeted product eligibility? The community discussion highlighted a couple of robust solutions:
1. Leveraging Custom Shopify Functions
For those with a developer on hand or a bit of coding savvy, a custom Shopify Function is a powerful answer. As ahsandoesntcare explained, you can create a custom app using the Product Discount API. This allows you to calculate the exact percentage discount based on the total line subtotal (quantity * price) and apply it as a fixed amount discount targeted to the line item, ensuring precision and integration with promo codes.
2. Using Specialized Discount Apps like Cart Marshal
Not everyone has a developer or wants to dive into custom code, and that's perfectly fine! This is where specialized apps come in. Josh-FiveAcreCode, the developer behind Cart Marshal, stepped in to offer his app as a solution. Cart Marshal can handle this scenario through a "targeted Order Discount" that:
- Applies the discount at the subtotal level, ensuring correct calculation.
- Allows you to restrict eligibility to specific products, collections, or tags.
- Supports discount codes (like Maria's
WELCOME10).
The best part? Cart Marshal offers a legitimately free tier for one rule, which covers Maria's exact use case. Dascalargo even chimed in to praise this!![]()
Setting Up a Targeted Order Discount in Cart Marshal:
If you're using Cart Marshal, here are the steps Josh-FiveAcreCode shared to configure an accurate, targeted discount:
- Choose Order Discount when creating your rule.
- Set it to Discount code.
- Enter your desired code, such as
WELCOME10. - Set the discount to your desired percentage, e.g., 10%.
- Restrict the eligible products using your collection or product criteria.
- Publish the rule.
This setup ensures your discount applies correctly to the subtotal of only the items you want it to.


The Cart Display Glitch: When Calculation is Right, but the Number Looks Wrong
Even after Maria successfully got Cart Marshal to calculate the discount correctly, she noticed another tricky issue: the displayed price per meter in the cart was still showing a rounded, incorrect value. For her €17/m product with a 10% discount, it should be €15.30/m, but Shopify was displaying €16/m. This is super confusing for customers!
Josh-FiveAcreCode quickly identified this as a Shopify unit-price display issue, not a calculation error. Shopify's native unit-price value rounds to cent precision, turning €0.153/cm into €0.16/cm, which then displays as €16/m. This is a theme-level problem, specifically with the Liquid code that renders unit prices.
Fixing the Display for Clarity:
To fix this, you'd need a small Liquid/theme change. The goal is to make your cart code calculate the effective discounted unit price from the final discounted line total, rather than relying on Shopify’s rounded native unit-price value. If you're using a theme like Minimog, a developer can help you pinpoint the relevant cart code to modify. This might involve adjusting the Liquid logic to divide the discounted line item total by the quantity to get the accurate per-unit discounted price. Don't hesitate to reach out to a Shopify expert or your theme's support team for assistance.
A Quick Alternative Idea
Josh-FiveAcreCode also threw out an interesting alternative: changing your product catalog to offer items by a larger unit, like the decimeter instead of the centimeter. This could potentially raise your base unit price enough to naturally avoid most rounding issues. It's not always feasible, but worth considering if it fits your product and customer experience.
Navigating these kinds of technical nuances can feel like a maze, but it’s crucial for maintaining customer trust and accurate accounting. Whether you opt for a custom Shopify Function, a specialized app like Cart Marshal, or a theme customization, ensuring your discounts are calculated and displayed correctly is paramount. It just goes to show that even in the seemingly straightforward world of e-commerce, a little community wisdom and expert insight can go a long way in keeping your store running smoothly and your customers happy. For store owners looking to start with Shopify, it's great to know these solutions exist to tackle complex pricing scenarios right from the get-go, making Shopify an even more powerful platform for your business when you set up your store.