update home to shipping address

This commit is contained in:
2024-09-27 17:59:27 +10:00
parent 38b3d5d367
commit beed9f9c11
9 changed files with 117 additions and 117 deletions

View File

@@ -29,21 +29,21 @@ let SM = {
copyContent().then(() => { /* empty */});
},
updateBillingAddress: () => {
const checkboxElement = document.querySelector('input[name="billing_same_home"]');
updateShippingAddress: () => {
const checkboxElement = document.querySelector('input[name="shipping_same_billing"]');
if (checkboxElement) {
const itemNames = ['address', 'address2', 'city', 'state', 'postcode', 'country'];
if (checkboxElement.checked) {
itemNames.forEach((itemName) => {
const element = document.querySelector(`input[name="billing_${itemName}"]`);
element.value = document.querySelector(`input[name="home_${itemName}"]`).value;
const element = document.querySelector(`input[name="shipping_${itemName}"]`);
element.value = document.querySelector(`input[name="billing_${itemName}"]`).value;
element.setAttribute('readonly', 'true');
});
} else {
itemNames.forEach((itemName) => {
const element = document.querySelector(`input[name="billing_${itemName}"]`);
const element = document.querySelector(`input[name="shipping_${itemName}"]`);
element.removeAttribute('readonly');
});
}
@@ -347,6 +347,6 @@ let SM = {
};
document.addEventListener('DOMContentLoaded', () => {
SM.updateBillingAddress();
SM.updateShippingAddress();
SM.updateAllThumbnails();
});