// Product Data
const products = {
vegPickles: [
{
id: 1,
name: "Avakaya (Mango Pickle)",
description: "The king of pickles; raw mango pieces with mustard and chili.",
price: 299,
originalPrice: 349,
image: "http://static.photos/food/640x360/5",
weightOptions: ["250g", "500g", "1kg"],
spiceLevel: 3,
shelfLife: "6 months",
ingredients: "Raw mango, mustard seeds, red chili powder, fenugreek, turmeric, salt, oil",
rating: 4.8,
isBestseller: true
},
{
id: 2,
name: "Bellam Avakaya",
description: "Sweet and spicy mango pickle made with Jaggery.",
price: 329,
originalPrice: 379,
image: "http://static.photos/food/640x360/6",
weightOptions: ["250g", "500g"],
spiceLevel: 2,
shelfLife: "6 months",
ingredients: "Raw mango, jaggery, mustard seeds, red chili powder, fenugreek, turmeric, salt, oil",
rating: 4.7,
isSpecial: true
},
// Add more veg pickles...
],
nonVegPickles: [
{
id: 101,
name: "Chicken Boneless Pickle",
description: "Tender chunks marinated in ginger-garlic and garam masala.",
price: 449,
originalPrice: 499,
image: "http://static.photos/food/640x360/7",
weightOptions: ["250g", "500g"],
spiceLevel: 3,
shelfLife: "3 months",
ingredients: "Chicken, ginger, garlic, garam masala, red chili powder, turmeric, salt, oil",
rating: 4.9,
isBestseller: true
},
// Add more non-veg pickles...
],
vadiyalu: [
{
id: 201,
name: "Gummadi Vadiyalu",
description: "Ash gourd (pumpkin) chunks mixed with urad dal batter.",
price: 199,
originalPrice: 249,
image: "http://static.photos/food/640x360/8",
weightOptions: ["250g", "500g", "1kg"],
spiceLevel: 1,
shelfLife: "12 months",
ingredients: "Ash gourd, urad dal, green chilies, salt",
rating: 4.5
},
// Add more vadiyalu...
],
masalas: [
{
id: 301,
name: "Biryani Masala",
description: "Hyderabadi-style aromatic blend.",
price: 149,
originalPrice: 179,
image: "http://static.photos/food/640x360/9",
weightOptions: ["100g", "250g"],
spiceLevel: 2,
shelfLife: "12 months",
ingredients: "Cinnamon, cardamom, cloves, bay leaves, star anise, mace, nutmeg, pepper",
rating: 4.7,
isNew: true
},
// Add more masalas...
]
};
// Cart System
let cart = JSON.parse(localStorage.getItem('cart')) || [];
let isLoggedIn = localStorage.getItem('isLoggedIn') === 'true';
// DOM Elements
const productGrids = {
veg: document.querySelector('#veg-pickles .product-grid'),
nonVeg: document.querySelector('#nonveg-pickles .product-grid'),
vadiyalu: document.querySelector('#vadiyalu .product-grid'),
masalas: document.querySelector('#masalas .product-grid')
};
// Initialize the app
document.addEventListener('DOMContentLoaded', () => {
renderProducts();
setupEventListeners();
// Check if user is logged in
if (isLoggedIn) {
updateUserUI();
}
});
// Render all products
function renderProducts() {
renderProductCategory('veg', products.vegPickles);
renderProductCategory('nonVeg', products.nonVegPickles);
renderProductCategory('vadiyalu', products.vadiyalu);
renderProductCategory('masalas', products.masalas);
}
// Render products for a specific category
function renderProductCategory(category, products) {
const grid = productGrids[category];
grid.innerHTML = '';
products.forEach(product => {
const productCard = document.createElement('div');
productCard.className = 'product-card';
productCard.innerHTML = `
${product.isBestseller ? 'Bestseller' : ''}
${product.isNew ? 'New' : ''}
${product.isSpecial ? 'Special' : ''}
Shelf Life: ${product.shelfLife}