Spaces:
Paused
Paused
Update app.py
Browse files
app.py
CHANGED
|
@@ -287,11 +287,18 @@ def catalog():
|
|
| 287 |
.clear-cart {
|
| 288 |
background-color: #e74c3c;
|
| 289 |
margin-top: 10px;
|
| 290 |
-
|
| 291 |
}
|
| 292 |
.clear-cart:hover {
|
| 293 |
background-color: #c0392b;
|
| 294 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 295 |
@media (max-width: 768px) {
|
| 296 |
body {
|
| 297 |
padding: 10px;
|
|
@@ -418,6 +425,7 @@ def catalog():
|
|
| 418 |
<div style="margin-top: 20px; text-align: right;">
|
| 419 |
<strong>Итого: <span id="cartTotal">0</span> ₽</strong>
|
| 420 |
<button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
|
|
|
|
| 421 |
</div>
|
| 422 |
</div>
|
| 423 |
</div>
|
|
@@ -566,6 +574,27 @@ def catalog():
|
|
| 566 |
document.getElementById('cartModal').style.display = 'block';
|
| 567 |
}
|
| 568 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 569 |
function clearCart() {
|
| 570 |
console.log("Очистка корзины");
|
| 571 |
localStorage.removeItem('cart');
|
|
|
|
| 287 |
.clear-cart {
|
| 288 |
background-color: #e74c3c;
|
| 289 |
margin-top: 10px;
|
| 290 |
+
margin-right: 10px;
|
| 291 |
}
|
| 292 |
.clear-cart:hover {
|
| 293 |
background-color: #c0392b;
|
| 294 |
}
|
| 295 |
+
.order-button {
|
| 296 |
+
background-color: #25D366;
|
| 297 |
+
margin-top: 10px;
|
| 298 |
+
}
|
| 299 |
+
.order-button:hover {
|
| 300 |
+
background-color: #20B956;
|
| 301 |
+
}
|
| 302 |
@media (max-width: 768px) {
|
| 303 |
body {
|
| 304 |
padding: 10px;
|
|
|
|
| 425 |
<div style="margin-top: 20px; text-align: right;">
|
| 426 |
<strong>Итого: <span id="cartTotal">0</span> ₽</strong>
|
| 427 |
<button class="product-button clear-cart" onclick="clearCart()">Очистить корзину</button>
|
| 428 |
+
<button class="product-button order-button" onclick="orderViaWhatsApp()">Заказать</button>
|
| 429 |
</div>
|
| 430 |
</div>
|
| 431 |
</div>
|
|
|
|
| 574 |
document.getElementById('cartModal').style.display = 'block';
|
| 575 |
}
|
| 576 |
|
| 577 |
+
function orderViaWhatsApp() {
|
| 578 |
+
const cart = JSON.parse(localStorage.getItem('cart') || '[]');
|
| 579 |
+
if (cart.length === 0) {
|
| 580 |
+
alert("Корзина пуста! Добавьте товары перед заказом.");
|
| 581 |
+
return;
|
| 582 |
+
}
|
| 583 |
+
|
| 584 |
+
let total = 0;
|
| 585 |
+
let orderText = "Заказ:%0A";
|
| 586 |
+
cart.forEach((item, index) => {
|
| 587 |
+
const itemTotal = item.price * item.quantity;
|
| 588 |
+
total += itemTotal;
|
| 589 |
+
orderText += `${index + 1}. ${item.name} - ${item.price} ₽ × ${item.quantity}%0A`;
|
| 590 |
+
});
|
| 591 |
+
orderText += `Итого: ${total} ₽`;
|
| 592 |
+
|
| 593 |
+
const whatsappUrl = `https://api.whatsapp.com/send?phone=996500398754&text=${orderText}`;
|
| 594 |
+
window.open(whatsappUrl, '_blank');
|
| 595 |
+
console.log("Переход в WhatsApp с заказом:", orderText);
|
| 596 |
+
}
|
| 597 |
+
|
| 598 |
function clearCart() {
|
| 599 |
console.log("Очистка корзины");
|
| 600 |
localStorage.removeItem('cart');
|