` ${Navbar()}

About TYQUNE CLOTHING

TYQUNE CLOTHING-এ আপনাকে স্বাগতম! আমরা গুণগত মানসম্পন্ন এবং আধুনিক পোশাক সরবরাহ করতে প্রতিশ্রুতিবদ্ধ। আমাদের লক্ষ্য হলো সাশ্রয়ী মূল্যে সেরা পণ্যটি আপনার কাছে পৌঁছে দেওয়া। প্রতিটি পণ্য যত্ন সহকারে তৈরি এবং আপনার রুচি ও পছন্দের কথা মাথায় রেখে ডিজাইন করা হয়েছে। আপনার কেনাকাটার অভিজ্ঞতা সেরা করতে আমরা সর্বদা প্রস্তুত।

${Footer()} `; const ContactUsPage = () => ` ${Navbar()}

Contact Us

Phone

+8809638-025118

Email

tyqune.clothing1@gmail.com

Instagram

@tyquneclothing
${Footer()} `; const CheckoutPage = () => ` ${Navbar()}

Checkout

Billing & Shipping

Your Order

Subtotal 0.00 ৳
Shipping
TOTAL 0.00 ৳
পণ্য হাতে পেয়ে টাকা পরিশোধ করুন
${Footer()} `; const ConfirmationPage = () => { const lastOrder = JSON.parse(localStorage.getItem('lastOrder')); if (!lastOrder) { return ShopPage(); } const { cart, shippingCost, total, orderId } = lastOrder; const subtotal = cart.reduce((sum, item) => sum + item.price * item.quantity, 0); return ` ${Navbar()}

ধন্যবাদ! আপনার অর্ডারটি সফল হয়েছে।

আমাদের একজন প্রতিনিধি শীঘ্রই আপনার সাথে যোগাযোগ করবে।

আপনার অর্ডার আইডি: ${orderId}

Order Summary

${cart.map(item => `
${item.name} - ${item.size} × ${item.quantity} ${(item.price * item.quantity).toFixed(2)} ৳
`).join('')}
Subtotal ${subtotal.toFixed(2)} ৳
Shipping ${shippingCost.toFixed(2)} ৳
TOTAL ${total.toFixed(2)} ৳
${Footer()} `; }; const pageContent = document.getElementById('page-content'); const modal = document.getElementById('product-modal'); const cartSidebar = document.getElementById('cart-sidebar'); const render = (templateFn) => { pageContent.innerHTML = templateFn(); updateCartUI(); if (document.getElementById('checkout-form')) { updateOrderSummary(); } }; const saveCart = () => { localStorage.setItem('shoppingCart', JSON.stringify(cart)); }; const openProductModal = (productId) => { const product = products.find(p => p.id === productId); if (!product) { return; } const modalContent = document.querySelector('.modal-content'); modalContent.innerHTML = `
${product.name}

${product.name}

${product.description || ''}

${product.price.toFixed(2)} ৳

${product.oldPrice.toFixed(2)} ৳

Sizes:

${(product.sizes || []).map(s => ``).join('')}

Quantity:

`; modal.classList.remove('hidden'); modal.classList.add('flex'); modal.dataset.productId = productId; }; const closeProductModal = () => { modal.classList.add('hidden'); modal.classList.remove('flex'); }; const addToCart = (product, size, quantity) => { if (!size) { document.getElementById('size-error')?.classList.remove('hidden'); return false; } const existingItem = cart.find(item => item.id === product.id && item.size === size); if (existingItem) { existingItem.quantity += quantity; } else { cart.push({ ...product, size, quantity }); } saveCart(); updateCartUI(); return true; }; const updateCartUI = () => { const cartItemsContainer = document.getElementById('cart-items'); const cartCount = document.getElementById('cart-count'); const cartSubtotal = document.getElementById('cart-subtotal'); const checkoutBtn = document.getElementById('checkout-btn'); if (!cartItemsContainer || !cartCount || !cartSubtotal || !checkoutBtn) return; if (cart.length === 0) { cartItemsContainer.innerHTML = '

Your cart is empty.

'; checkoutBtn.disabled = true; } else { cartItemsContainer.innerHTML = cart.map(item => `
${item.name}

${item.name}

Size: ${item.size}

${item.price.toFixed(2)} ৳

Qty

${item.quantity}

`).join(''); checkoutBtn.disabled = false; } const subtotal = cart.reduce((sum, item) => sum + item.price * item.quantity, 0); const totalQuantity = cart.reduce((sum, item) => sum + item.quantity, 0); cartSubtotal.textContent = `${subtotal.toFixed(2)} ৳`; cartCount.textContent = totalQuantity; cartCount.classList.toggle('hidden', totalQuantity === 0); }; const removeFromCart = (productId, size) => { cart = cart.filter(item => !(item.id === productId && item.size === size)); saveCart(); updateCartUI(); }; function updateOrderSummary() { const orderItemsContainer = document.getElementById('order-summary-items'); const subtotalSpan = document.getElementById('summary-subtotal'); const totalSpan = document.getElementById('summary-total'); const shippingInput = document.querySelector('input[name="shipping"]:checked'); if (!orderItemsContainer || !subtotalSpan || !totalSpan || !shippingInput) return; const subtotal = cart.reduce((sum, item) => sum + item.price * item.quantity, 0); const shippingCost = parseFloat(shippingInput.value); const total = subtotal + shippingCost; if(orderItemsContainer) { orderItemsContainer.innerHTML = cart.map(item => `
${item.name} - ${item.size} × ${item.quantity} ${(item.price * item.quantity).toFixed(2)} ৳
`).join(''); } if(subtotalSpan) subtotalSpan.textContent = `${subtotal.toFixed(2)} ৳`; if(totalSpan) totalSpan.textContent = `${total.toFixed(2)} ৳`; } const openCart = () => cartSidebar.classList.add('open'); const closeCart = () => cartSidebar.classList.remove('open'); async function handlePlaceOrder(placeOrderBtn) { const form = document.getElementById('checkout-form'); let isFormValid = true; form.querySelectorAll('[required]').forEach(input => { if (!input.value.trim()) { input.classList.add('invalid-field'); isFormValid = false; } else { input.classList.remove('invalid-field'); } }); if (!isFormValid) { return; } if (GOOGLE_SCRIPT_URL === 'YOUR_GOOGLE_SCRIPT_URL') { alert('অনুগ্রহ করে কোডের মধ্যে আপনার Google Script URL যোগ করুন।'); return; } placeOrderBtn.disabled = true; placeOrderBtn.textContent = 'Processing...'; const orderId = `TYQ-${Date.now()}`; const shippingCost = parseFloat(document.querySelector('input[name="shipping"]:checked').value); const total = cart.reduce((sum, item) => sum + item.price * item.quantity, 0) + shippingCost; const orderData = { orderId: orderId, customerName: form.name.value, customerAddress: form.address.value, customerPhone: form.phone.value, orderNotes: form.notes.value, orderDetails: cart.map(item => `${item.name} (Size: ${item.size}) x${item.quantity}`).join(', '), totalPrice: `${total.toFixed(2)} ৳` }; try { await fetch(GOOGLE_SCRIPT_URL, { method: 'POST', mode: 'no-cors', cache: 'no-cache', headers: { 'Content-Type': 'application/json' }, redirect: 'follow', body: JSON.stringify(orderData) }); console.log('Order data submission attempted.'); const lastOrder = { orderId: orderId, cart: [...cart], customer: { name: form.name.value, address: form.address.value, phone: form.phone.value, notes: form.notes.value }, shippingCost: shippingCost, total: total }; localStorage.setItem('lastOrder', JSON.stringify(lastOrder)); cart = []; saveCart(); render(ConfirmationPage); } catch (error) { console.error('Error submitting order to Google Sheet:', error); alert('দুঃখিত, আপনার অর্ডারটি সম্পন্ন করা যায়নি। অনুগ্রহ করে আবার চেষ্টা করুন।'); placeOrderBtn.disabled = false; placeOrderBtn.textContent = 'Place Order'; } } function setupEventListeners() { document.body.addEventListener('click', e => { const target = e.target; if (target.closest('.select-options-btn')) { const productId = parseInt(target.closest('.select-options-btn').dataset.id); openProductModal(productId); } if (target.closest('#cart-icon')) openCart(); if (target.closest('#close-cart-btn')) closeCart(); if (target.closest('.home-link')) { e.preventDefault(); render(ShopPage); } if (target.closest('.about-link')) { e.preventDefault(); render(AboutUsPage); } if (target.closest('.contact-link')) { e.preventDefault(); render(ContactUsPage); } if (target.closest('#checkout-btn')) { if (cart.length > 0) { closeCart(); render(CheckoutPage); // FIX: Call updateOrderSummary after rendering checkout page setTimeout(updateOrderSummary, 0); } } if (target.closest('.remove-from-cart')) { const btn = target.closest('.remove-from-cart'); const productId = parseInt(btn.dataset.id); const size = btn.dataset.size; removeFromCart(productId, size); } if (target.closest('#place-order-btn')) { const btn = target.closest('#place-order-btn'); if (!btn.disabled) { e.preventDefault(); handlePlaceOrder(btn); } } if (target.closest('#back-to-home-btn')) { render(ShopPage); } }); const modal = document.getElementById('product-modal'); modal.addEventListener('click', e => { const target = e.target; const productId = parseInt(modal.dataset.productId); if (!productId) return; const product = products.find(p => p.id === productId); if(!product) return; if (target.closest('.close-modal-btn')) closeProductModal(); if (target.closest('.size-btn')) { const modalContent = document.querySelector('.modal-content'); modalContent.querySelectorAll('.size-btn').forEach(b => b.classList.remove('selected')); target.closest('.size-btn').classList.add('selected'); } if (target.closest('.quantity-change')) { const change = parseInt(target.dataset.change); const input = document.getElementById('quantity-input'); let currentValue = parseInt(input.value) + change; if (currentValue < 1) currentValue = 1; input.value = currentValue; } if (target.closest('#add-to-cart-modal')) { const quantity = parseInt(document.getElementById('quantity-input').value); const selectedSizeEl = document.querySelector('#product-modal .size-btn.selected'); const selectedSize = selectedSizeEl ? selectedSizeEl.dataset.size : null; if (addToCart(product, selectedSize, quantity)) { closeProductModal(); openCart(); } } if (target.closest('#order-now-modal')) { const quantity = parseInt(document.getElementById('quantity-input').value); const selectedSizeEl = document.querySelector('#product-modal .size-btn.selected'); const selectedSize = selectedSizeEl ? selectedSizeEl.dataset.size : null; if (addToCart(product, selectedSize, quantity)) { closeProductModal(); render(CheckoutPage); } } }); document.body.addEventListener('change', e => { if (e.target.name === 'shipping') { updateOrderSummary(); } }); } document.addEventListener('DOMContentLoaded', () => { setupEventListeners(); render(ShopPage); }); //]]>