👑
💎
👑

Your Crown Order

Subtotal: $0.00
Shipping: FREE
Tax: $0.00
Total: $0.00

Royal Payment

Credit Card
PayPal

Billing Address

Pay with PayPal

PayPal accepts all major credit cards and debit cards, plus PayPal balance. Your payment information is protected by PayPal's secure checkout.

🔒 Your payment is secure

We use industry-standard encryption to protect your information

🛡️ SSL Secured 💳 PCI Compliant ✅ Verified
, '')), size: cartItem.size }); } catch (e) { // Fallback for old system const selectedProduct = sessionStorage.getItem('selectedProduct'); if (selectedProduct && products[selectedProduct]) { const product = products[selectedProduct]; orderItems.push({ title: product.name, selectedColor: 'Default', quantity: quantity, price: product.price, size: 'Standard' }); } } } // Get customer information from form const customerInfo = { firstName: document.getElementById('name').value.split(' ')[0] || 'Customer', lastName: document.getElementById('name').value.split(' ').slice(1).join(' ') || '', email: document.getElementById('email').value || 'customer@example.com', phone: '' // Not collected in current form }; // Get shipping/billing information const shippingInfo = { address: document.getElementById('address').value || '', city: document.getElementById('city').value || '', province: document.getElementById('state').value || '', postalCode: document.getElementById('zip').value || '', country: 'United States' // Default for now }; // Calculate totals const subtotal = orderItems.reduce((sum, item) => sum + (item.price * item.quantity), 0); const tax = subtotal * 0.08; const total = subtotal + tax; // Create order object const order = { id: 'ORD-' + Date.now(), customerInfo: customerInfo, shippingInfo: shippingInfo, billingInfo: shippingInfo, // Same as shipping for now items: orderItems, subtotal: subtotal, tax: tax, shipping: 0, // Free shipping total: total, paymentMethod: paymentMethod, paymentStatus: 'completed', status: 'pending', createdAt: new Date().toISOString(), updatedAt: new Date().toISOString() }; // Save order to localStorage for admin dashboard try { const existingOrders = JSON.parse(localStorage.getItem('adetutu_orders') || '[]'); existingOrders.push(order); localStorage.setItem('adetutu_orders', JSON.stringify(existingOrders)); console.log('✅ Order saved to admin dashboard:', order.id); // Log activity const activity = JSON.parse(localStorage.getItem('adetutu_activity') || '[]'); activity.push({ message: `New order received: ${order.id} - ${total.toFixed(2)} via ${paymentMethod}`, timestamp: new Date().toISOString() }); localStorage.setItem('adetutu_activity', JSON.stringify(activity)); // Send email notification if EmailJS is configured sendOrderNotificationFromCheckout(order); return order; } catch (error) { console.error('❌ Failed to save order:', error); return null; } } function sendOrderNotificationFromCheckout(order) { // Check if EmailJS is configured const emailConfig = localStorage.getItem('adetutu_email_config'); if (!emailConfig) { console.log('📧 EmailJS not configured, skipping notification'); return; } try { const config = JSON.parse(emailConfig); if (!config.publicKey || !config.serviceId || !config.templateId) { console.log('📧 EmailJS configuration incomplete'); return; } // Initialize EmailJS if not already done emailjs.init(config.publicKey); const templateParams = { to_email: config.adminEmail, order_id: order.id, customer_name: order.customerInfo.firstName + ' ' + order.customerInfo.lastName, customer_email: order.customerInfo.email, order_total: ' overlay.style.cssText = ` position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(26, 15, 10, 0.95); display: flex; align-items: center; justify-content: center; z-index: 10000; animation: fadeIn 0.5s ease; `; overlay.innerHTML = `
👑

Order Confirmed!

Your royal crown is on its way! Payment processed successfully via ${paymentMethod}.

Order #AH${Date.now().toString().slice(-6)}

You'll receive a confirmation email shortly

`; document.body.appendChild(overlay); // Add animations const style = document.createElement('style'); style.textContent = ` @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } `; document.head.appendChild(style); // Clear cart sessionStorage.removeItem('selectedProduct'); } // Card number formatting document.getElementById('card-number').addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); value = value.replace(/(\d{4})(?=\d)/g, '$1 '); e.target.value = value; }); // Expiry date formatting document.getElementById('expiry').addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); if (value.length >= 2) { value = value.substring(0, 2) + '/' + value.substring(2, 4); } e.target.value = value; }); // CVV formatting document.getElementById('cvv').addEventListener('input', function(e) { e.target.value = e.target.value.replace(/\D/g, '').substring(0, 4); }); + order.total.toFixed(2), order_items: order.items.map(item => `${item.title} (${item.selectedColor}) x${item.quantity} - ${(item.price * item.quantity).toFixed(2)}` ).join('\n'), shipping_address: `${order.shippingInfo.address}\n${order.shippingInfo.city}, ${order.shippingInfo.province} ${order.shippingInfo.postalCode}\n${order.shippingInfo.country}`, order_date: new Date(order.createdAt).toLocaleDateString() }; emailjs.send(config.serviceId, config.templateId, templateParams) .then(function(response) { console.log('✅ Order notification sent:', response.status); }, function(error) { console.error('❌ Failed to send order notification:', error); }); } catch (error) { console.error('❌ Error sending order notification:', error); } } function showSuccessMessage(paymentMethod) { // Save order to admin dashboard first const order = saveOrderToAdmin(paymentMethod); // Create success overlay const overlay = document.createElement('div'); overlay.style.cssText = ` position: fixed; top: 0; left: 0; width: 100vw; height: 100vh; background: rgba(26, 15, 10, 0.95); display: flex; align-items: center; justify-content: center; z-index: 10000; animation: fadeIn 0.5s ease; `; overlay.innerHTML = `
👑

Order Confirmed!

Your royal crown is on its way! Payment processed successfully via ${paymentMethod}.

Order #AH${Date.now().toString().slice(-6)}

You'll receive a confirmation email shortly

`; document.body.appendChild(overlay); // Add animations const style = document.createElement('style'); style.textContent = ` @keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } } @keyframes slideUp { from { transform: translateY(50px); opacity: 0; } to { transform: translateY(0); opacity: 1; } } `; document.head.appendChild(style); // Clear cart sessionStorage.removeItem('selectedProduct'); } // Card number formatting document.getElementById('card-number').addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); value = value.replace(/(\d{4})(?=\d)/g, '$1 '); e.target.value = value; }); // Expiry date formatting document.getElementById('expiry').addEventListener('input', function(e) { let value = e.target.value.replace(/\D/g, ''); if (value.length >= 2) { value = value.substring(0, 2) + '/' + value.substring(2, 4); } e.target.value = value; }); // CVV formatting document.getElementById('cvv').addEventListener('input', function(e) { e.target.value = e.target.value.replace(/\D/g, '').substring(0, 4); });