32 lines
1.0 KiB
Python
32 lines
1.0 KiB
Python
from db.models import Product
|
||
from dto.cart import CartDTO
|
||
|
||
product_editing_mapping = {
|
||
"name": "новое название",
|
||
"description": "новое описание",
|
||
"price": "новую цену",
|
||
}
|
||
|
||
|
||
def get_product_description(product: Product) -> str:
|
||
output = f"📦 <b>{product.name}</b>\n\n<b>🏷️ {product.price}₽</b>"
|
||
if product.description:
|
||
output += f"\n\n📜 <b><i>{product.description}</i></b>"
|
||
|
||
return output
|
||
|
||
|
||
def get_order_item_list(cart: CartDTO):
|
||
text = "🛍 Состав заказа:\n"
|
||
for i, product in enumerate(cart.items):
|
||
text += f"\n{i+1}. <b>{product.name}</b>\n•\t<i>{product.quantity} × {product.price} = {product.total}₽</i>\n"
|
||
|
||
text += f"\n━━━━━━━━━━━━━━\n💰 Итого: {cart.total}₽"
|
||
|
||
return text
|
||
|
||
|
||
def get_breadcrumps_path(products: list[Product]) -> str:
|
||
products_str = f" -> {' -> '.join([x.name for x in products])}" if products else ""
|
||
return f"<b>🏠 Каталог{products_str}</b>"
|