Apply discounts before summing the cart !1
Versions
Ready to merge
Changes in v1 against the merge base with main
1 file changed+2−0
- Modified:cart.go+2−0
cart.go +2−0
| Old line | New line | Change | Code |
|---|---|---|---|
| @@ -43,3 +43,5 @@ func showCart(w http.ResponseWriter, r *http.Request) { | |||
| 43 | 43 | } | |
| 44 | 44 | ||
| 45 | 45 | func validQuantity(q int) bool { return q > 0 && q <= 99 } | |
| 46 | added | ||
| 47 | added | func discounted(p Product) float64 { return p.Price * (1 - p.Discount) } | |