Sortie16

Product Landing Page


function changeImage(image) { document.getElementById('mainImage').src = image; } document.getElementById('orderForm').addEventListener('submit', async function(event) { event.preventDefault(); const email = "rayah.a@mdinjdida.com"; const apiKey = "NT2zlp22F3615GM8788I4L272DWx9rcf"; const token = btoa(`${email}:${apiKey}`); const orderData = { user_id: "0", payment_id: "12", shipping_id: "10", products: { "1": { product_id: "6800", amount: "1" } }, user_data: { email: "guest10101010@example.com", firstname: document.getElementById('fullName').value, lastname: "Guest", s_firstname: "Guest", s_lastname: "Guest", s_country: "DZ", s_city: document.getElementById('state').value, s_state: "02", s_address: document.getElementById('address').value, s_phone: document.getElementById('phone').value, b_firstname: document.getElementById('fullName').value, b_lastname: "Guest", b_country: "DZ", b_city: document.getElementById('state').value, b_state: "02", b_address: document.getElementById('address').value, b_phone: document.getElementById('phone').value, } }; try { const response = await fetch('https://www.mdinjdida.com/api/orders', { method: 'POST', headers: { 'Content-Type': 'application/json', 'Authorization': `Basic ${token}` }, body: JSON.stringify(orderData) }); const data = await response.json(); alert('Order placed successfully!'); } catch (error) { console.error('Error:', error); } });