personal discounts to businesses done
This commit is contained in:
@@ -4,11 +4,16 @@ use serde_json::{json, Value};
|
||||
|
||||
use crate::models::_entities::{categories, products};
|
||||
use crate::shared::money::format_price;
|
||||
use crate::shared::pricing::PricedProduct;
|
||||
|
||||
/// Card/list shape for a product: model fields plus a formatted price, its
|
||||
/// optional primary image filename and category name.
|
||||
/// Card/list shape for a product: model fields plus the viewer's resolved price
|
||||
/// (from [`crate::shared::pricing`]), its optional primary image and category.
|
||||
/// `on_sale` means "render the price as reduced" — driven by the resolved price,
|
||||
/// so it covers both public sales and business deals; `is_business` flags the
|
||||
/// latter.
|
||||
pub fn product_card(
|
||||
product: &products::Model,
|
||||
priced: &PricedProduct,
|
||||
image: Option<String>,
|
||||
category_name: Option<String>,
|
||||
) -> Value {
|
||||
@@ -17,9 +22,10 @@ pub fn product_card(
|
||||
"name": product.name,
|
||||
"slug": product.slug,
|
||||
"description": product.description,
|
||||
"price": format_price(product.effective_price_cents()),
|
||||
"on_sale": product.on_sale(),
|
||||
"regular_price": format_price(product.price_cents),
|
||||
"price": format_price(priced.price_cents),
|
||||
"on_sale": priced.is_reduced(),
|
||||
"is_business": priced.is_business,
|
||||
"regular_price": format_price(priced.regular_cents),
|
||||
"currency": product.currency,
|
||||
"sku": product.sku,
|
||||
"stock": product.stock,
|
||||
|
||||
Reference in New Issue
Block a user