×
@@ -1471,7 +1531,7 @@ def category_products(category):
Главная
-
+
Каталог
@@ -1510,51 +1570,6 @@ def category_products(category):
document.querySelector('.theme-toggle i').classList.replace('fa-moon', 'fa-sun');
}
- function loadFavoritesPage() {
- const favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
- const productsGrid = document.getElementById('products-grid');
- productsGrid.innerHTML = '';
-
- if (favorites.length === 0) {
- productsGrid.innerHTML = '
Избранное пусто
';
- return;
- }
-
- favorites.forEach(index => {
- const product = products[index];
- if (!product) return;
- const productElement = document.createElement('div');
- productElement.className = 'product';
- productElement.setAttribute('onclick', `openModal(${index})`);
- productElement.setAttribute('data-name', product.name.toLowerCase());
- productElement.setAttribute('data-description', product.description.toLowerCase());
- productElement.setAttribute('data-category', product.category || 'Без категории');
- productElement.innerHTML = `
-
- ${product.photos && product.photos.length > 0 ? `
-
-

-
` : ''}
- ${product.discount ? `
Скидка ${product.discount}%` : ''}
-
${product.name}
-
- {% if product.get('discount') %}
- {{ product['price'] }} с
- {{ (product['price'] * (1 - product.discount / 100)).toFixed(2)} с
- Скидка: {{ product['discount'] }}%
- {% else %}
- {{ product['price'] }} с
- {% endif %}
-
-
${product.description.slice(0, 50)}${product.description.length > 50 ? '...' : ''}
-
- `;
- productsGrid.appendChild(productElement);
- });
- }
-
function openModal(index) {
loadProductDetails(index);
document.getElementById('productModal').style.display = "block";
@@ -1625,10 +1640,13 @@ def category_products(category):
if (product.discount) {
priceToUse = product.price * (1 - product.discount / 100);
}
+ if (product.min_wholesale && quantity >= product.min_wholesale) {
+ priceToUse = product.wholesale_price;
+ }
if (existingItem) {
existingItem.quantity += quantity;
- existingItem.price = (product.discount ? product.price * (1 - product.discount / 100) : product.price);
+ existingItem.price = (existingItem.quantity >= product.min_wholesale) ? product.wholesale_price : (product.discount ? product.price * (1 - product.discount / 100) : product.price);
} else {
cart.push({
id: cartItemId,
@@ -1669,6 +1687,7 @@ def category_products(category):
${item.name}
${item.price} с × ${item.quantity} (Цвет: ${item.color})
+
${item.quantity >= item.min_wholesale ? 'Оптовая цена' : (item.discount ? 'Скидка ' + item.discount + '%' : 'Розничная цена')}
@@ -1694,7 +1713,7 @@ def category_products(category):
orderText += `${index + 1}. ${item.name} - ${item.price} с × ${item.quantity} (Цвет: ${item.color})%0A`;
});
orderText += `Итого: ${total} с`;
- window.open('https://api.whatsapp.com/send?phone=996700666692&text=\${orderText}', '_blank');
+ window.open(`https://api.whatsapp.com/send?phone=996500654659&text=${orderText}`, '_blank');
}
function clearCart() {
@@ -1715,214 +1734,1617 @@ def category_products(category):
favoriteButton.classList.add('favorited');
}
localStorage.setItem('favorites', JSON.stringify(favorites));
- loadFavoritesPage();
}
+ function loadFavorites() {
+ const favorites = JSON.parse(localStorage.getItem('favorites') || '[]');
+ document.querySelectorAll('.favorite-button').forEach(button => {
+ const index = button.getAttribute('onclick').match(/\d+/)[0];
+ if (favorites.includes(index)) {
+ button.classList.add('favorited');
+ }
+ });
+ }
+
+
window.onclick = function(event) {
if (event.target.className === 'modal') event.target.style.display = "none";
}
updateCartButton();
- loadFavoritesPage();
+ loadFavorites();