From 49d64d397e93334f4505992773b5fad4980d8d30 Mon Sep 17 00:00:00 2001 From: Priec Date: Wed, 29 Jul 2026 22:54:45 +0200 Subject: [PATCH] cena on multiple choice --- assets/i18n/en/main.ftl | 1 + assets/i18n/sk/main.ftl | 1 + assets/views/shop/show.html | 20 +++++++++++++++++++- src/views/shop.rs | 3 +++ 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/assets/i18n/en/main.ftl b/assets/i18n/en/main.ftl index 7320745..d297d03 100644 --- a/assets/i18n/en/main.ftl +++ b/assets/i18n/en/main.ftl @@ -304,6 +304,7 @@ quantity = Quantity add-to-cart = To cart cart-added = Added to cart in-stock = In stock +price-for-quantity = Total for this quantity: out-of-stock = Out of stock gallery-prev = Previous image gallery-next = Next image diff --git a/assets/i18n/sk/main.ftl b/assets/i18n/sk/main.ftl index 1f15ca0..a33c626 100644 --- a/assets/i18n/sk/main.ftl +++ b/assets/i18n/sk/main.ftl @@ -304,6 +304,7 @@ quantity = Množstvo add-to-cart = Do košíka cart-added = Pridané do košíka in-stock = Na sklade +price-for-quantity = Cena za zvolené množstvo: out-of-stock = Vypredané gallery-prev = Predchádzajúci obrázok gallery-next = Ďalší obrázok diff --git a/assets/views/shop/show.html b/assets/views/shop/show.html index 9284ac5..46fb00b 100644 --- a/assets/views/shop/show.html +++ b/assets/views/shop/show.html @@ -78,7 +78,15 @@ x-data="{ variants: JSON.parse(document.getElementById('variant-data').textContent) || [], sel: 0, + qty: 1, get current() { return this.variants[this.sel] || null }, + /* Informational line total for the typed quantity. Mirrors the server's + format_price (minor units -> '12.34'); the currency symbol is appended + in the markup, as everywhere else. */ + get lineTotal() { + const cents = (this.current ? this.current.price_cents : 0) * Math.max(1, this.qty || 1); + return Math.floor(cents / 100) + '.' + String(cents % 100).padStart(2, '0'); + }, init() { const firstInStock = this.variants.findIndex(v => v.in_stock); this.sel = Math.max(0, firstInStock); @@ -139,10 +147,20 @@
- +
+ {# Informational only — what the typed quantity costs in total; the + cart recomputes it server-side. Hidden at qty 1, where it would + just repeat the unit price. #} +