document.addEventListener("DOMContentLoaded", function () {
// Grab values from the DOM
const propertyTitle = document.querySelector('[name="acf[field_property_title]"]')?.value || '';
const whatsappNumber = document.querySelector('[name="acf[main_whatsapp_number]"]')?.value || '';
if (propertyTitle && whatsappNumber) {
const encodedMessage = encodeURIComponent(`Hi, I want more information about this property: "${propertyTitle}"`);
const whatsappURL = `https://wa.me/${whatsappNumber}?text=${encodedMessage}`;
// Find the WhatsApp button and update its href
const waButton = document.querySelector('a[href^="https://wa.me"]');
if (waButton) {
waButton.setAttribute('href', whatsappURL);
}
}
});
Optimized by Seraphinite Accelerator Turns on site high speed to be attractive for people and search engines.