CZK implemented

This commit is contained in:
Priec
2026-06-23 12:54:11 +02:00
parent 6b7422806f
commit c409e85995
31 changed files with 606 additions and 51 deletions

View File

@@ -3,7 +3,7 @@
use serde_json::{json, Value};
use crate::models::_entities::{categories, product_images, product_variants, products};
use crate::shared::money::format_price;
use crate::shared::currency::Currency;
use crate::shared::pricing::PricedProduct;
/// Card/list shape for a product: model fields plus the viewer's resolved price
@@ -20,6 +20,7 @@ pub fn product_card(
variant_count: usize,
image: Option<String>,
category_name: Option<String>,
cur: &Currency,
) -> Value {
json!({
"id": product.id,
@@ -28,10 +29,10 @@ pub fn product_card(
"slug": product.slug,
"description": product.description,
"short_description": product.short_description,
"price": format_price(priced.price_cents),
"price": cur.format(priced.price_cents),
"on_sale": priced.is_reduced(),
"is_business": priced.is_business,
"regular_price": format_price(priced.regular_cents),
"regular_price": cur.format(priced.regular_cents),
"sku": representative.sku,
"stock": representative.stock,
"tracked": representative.tracked(),
@@ -45,7 +46,11 @@ pub fn product_card(
}
/// One priced variant row for the product detail page's option picker.
pub fn variant_option(variant: &product_variants::Model, priced: &PricedProduct) -> Value {
pub fn variant_option(
variant: &product_variants::Model,
priced: &PricedProduct,
cur: &Currency,
) -> Value {
json!({
"id": variant.id,
"label": variant.label,
@@ -53,9 +58,9 @@ pub fn variant_option(variant: &product_variants::Model, priced: &PricedProduct)
"stock": variant.stock,
"tracked": variant.tracked(),
"in_stock": variant.in_stock(),
"price": format_price(priced.price_cents),
"price": cur.format(priced.price_cents),
"on_sale": priced.is_reduced(),
"regular_price": format_price(priced.regular_cents),
"regular_price": cur.format(priced.regular_cents),
"is_business": priced.is_business,
})
}