|
|
|
|
@ -131,16 +131,23 @@ |
|
|
|
|
const subtotalAmount = document.getElementById('subtotal-amount'); |
|
|
|
|
const discountAmount = document.getElementById('discount-amount'); |
|
|
|
|
const finalTotal = document.getElementById('final-total'); |
|
|
|
|
const shippingForm = document.getElementById('shipping-form'); |
|
|
|
|
|
|
|
|
|
// Get address input elements directly |
|
|
|
|
const streetAddress = document.getElementById('street-address'); |
|
|
|
|
const apartment = document.getElementById('apartment'); |
|
|
|
|
const postalCode = document.getElementById('postal-code'); |
|
|
|
|
const city = document.getElementById('city'); |
|
|
|
|
const country = document.getElementById('country'); |
|
|
|
|
|
|
|
|
|
// Function to collect shipping address data |
|
|
|
|
function getShippingData() { |
|
|
|
|
const formData = new FormData(shippingForm); |
|
|
|
|
const shippingData = {}; |
|
|
|
|
formData.forEach((value, key) => { |
|
|
|
|
shippingData[key] = value; |
|
|
|
|
}); |
|
|
|
|
return shippingData; |
|
|
|
|
return { |
|
|
|
|
street_address: streetAddress ? streetAddress.value : '', |
|
|
|
|
apartment: apartment ? apartment.value : '', |
|
|
|
|
postal_code: postalCode ? postalCode.value : '', |
|
|
|
|
city: city ? city.value : '', |
|
|
|
|
country: country ? country.value : '' |
|
|
|
|
}; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// Initial values |
|
|
|
|
|