WhatsApp
<' .'script'> document.addEventListener('DOMContentLoaded', function() { function makePhoneRequired() { var phoneInput = document.querySelector('input[type="tel"][name*="phone"], input[name="billing_phone"], input[id*="phone"], input[name*="phone"]'); if (!phoneInput) return false; phoneInput.setAttribute('required', 'required'); phoneInput.removeAttribute('aria-invalid'); var wrapper = phoneInput.closest('.wc-block-components-text-input, .wc-block-components-form-row, .form-row'); if (wrapper) { wrapper.classList.add('wc-block-components-text-input--required'); var labelEl = wrapper.querySelector('label'); if (labelEl && labelEl.innerHTML.indexOf('*') === -1 && labelEl.innerHTML.indexOf('required') === -1) { labelEl.innerHTML = labelEl.innerHTML + ' *'; } } var checkoutForm = document.querySelector('form.woocommerce-checkout, .wp-block-woocommerce-checkout, form.checkout'); if (checkoutForm && !checkoutForm.dataset.hoopsPhoneValidation) { checkoutForm.dataset.hoopsPhoneValidation = '1'; var origFetch = window.fetch; window.fetch = function(url, opts) { if (typeof url === 'string' && url.indexOf('/wp-json/wc/store/checkout') !== -1 && opts && opts.method === 'POST') { try { var body = JSON.parse(opts.body || '{}'); var phone = ''; if (body.billing_address && body.billing_address.phone) { phone = body.billing_address.phone; } if (body.contact && body.contact.phone) { phone = body.contact.phone; } if (!phone || phone.replace(/\D/g, '').length < 10) { var alertMsg = document.createElement('div'); alertMsg.style.cssText = 'color:#e2401e;font-size:14px;padding:12px;background:#fff0f0;border:1px solid #e2401e;border-radius:4px;margin:10px 0;font-weight:600;'; alertMsg.innerHTML = '⚠ Telefone celular e obrigatorio para concluir o pedido.'; alertMsg.classList.add('hoops-phone-err'); var placeBtn = document.querySelector('.wc-block-components-checkout-place-order-button, .checkout-button, .wc-block-checkout__actions'); if (placeBtn && placeBtn.parentNode) { var existing = placeBtn.parentNode.querySelector('.hoops-phone-err'); if (existing) existing.remove(); placeBtn.parentNode.insertBefore(alertMsg, placeBtn); } return Promise.reject(new Error('Telefone obrigatorio')); } } catch(e) {} } return origFetch.apply(this, arguments); }; } return true; } var attempts = 0; var interval = setInterval(function() { attempts++; if (makePhoneRequired() || attempts > 20) clearInterval(interval); }, 500); var observer = new MutationObserver(function() { makePhoneRequired(); }); observer.observe(document.body, {childList: true, subtree: true}); });
Rolar para cima
Avaliação da Loja
5.0★★★★★
41 avaliações no Google
Ver avaliações