Free shipping thresholds are applied correctly
Why it matters
A free shipping threshold that is hardcoded in two places with different values — $50 in lib/shipping.ts and $100 in components/CartSummary.tsx — is a CWE-682 defect that will apply free shipping to some customers who don't qualify and deny it to others who do. ISO 25010:2011 functional correctness requires a single source of truth for business rule constants. Inconsistent thresholds also break customer trust: the cart banner says "Add $10 for free shipping" but the checkout still charges $12.99 after the customer crosses the threshold. This produces support tickets and abandoned carts at the highest-intent stage of the funnel.
Severity rationale
Medium because threshold inconsistency produces incorrect customer-facing charges and promotional failures that erode trust and generate refund requests.
Remediation
Define the threshold once in lib/shipping.ts (or a shared config file) and reference it everywhere — never hardcode the value in component files:
// lib/shipping.ts
export const FREE_SHIPPING_THRESHOLD_CENTS = 10_000 // $100.00
export function applyFreeShippingThreshold(
subtotalCents: number,
baseShipping: number
): number {
return subtotalCents >= FREE_SHIPPING_THRESHOLD_CENTS ? 0 : baseShipping
}
Import FREE_SHIPPING_THRESHOLD_CENTS in components/CartSummary.tsx for the promotional banner calculation so the display threshold and the charge threshold are always in sync. If the threshold is configurable per region or campaign, store it in an environment variable or database row, not a scattered literal.
DetectionPro
The detection method for this pattern is part of AuditBuffet Pro.
The full method (what to look for, pass and fail conditions, and how results get reported) ships inside the Shipping & Tax Audit. The pattern definition, severity rationale, and remediation remain openly licensed under CC-BY-4.0.
External references
- cwe · CWE-682 — Incorrect Calculation
- iso-25010:2011 · functional-correctness — Functional Correctness (Functional Suitability)
Taxons
History
- 2026-04-18·v1.0.0·Initial import from ecommerce-shipping-tax·automated