feat(shop): show sale badge and strikethrough price on discounted products

Products with compareAtPrice set now show a "-XX%" badge over the
image plus a struck-through original price, wherever price is
displayed (shop grid, homepage spotlight, cart line items). Also
switched the "inkl. MwSt. zzgl. Versand" rows on Pricing.tsx and
ProductSpotlight from items-center to items-baseline — with a large
price next to small disclosure text, center alignment left the
small text visibly floating above the price's bottom edge.
This commit is contained in:
Marco
2026-07-19 23:31:35 +00:00
parent 2a14e18aa1
commit 7b35b3e55b
5 changed files with 43 additions and 11 deletions
+9
View File
@@ -10,6 +10,15 @@ export function formatPrice(value: number): string {
return `${value.toFixed(2).replace(".", ",")}`;
}
// null when there's nothing to advertise — compareAtPrice unset, or set
// but not actually higher than price (e.g. cleared back down without
// nulling the field). Callers use this both to gate whether to render
// strikethrough/badge UI at all and to fill in the "-XX%" label.
export function discountPercent(price: number, compareAtPrice: number | null): number | null {
if (compareAtPrice === null || compareAtPrice <= price) return null;
return Math.round((1 - price / compareAtPrice) * 100);
}
const MONTHS_DE = [
"Januar", "Februar", "März", "April", "Mai", "Juni",
"Juli", "August", "September", "Oktober", "November", "Dezember",