How can I set up my checkout page so it opens in a new tab while still maintaining the regular WooCommerce behavior when the user presses the confirm purchase button?
I want to add a new method to the WooCommerce button so it opens a new tab.
I tried this in a Elementor HTML block:
<script>
document.addEventListener('DOMContentLoaded', function() {
var abrirContratoButton = document.getElementById('place_order');
if (abrirContratoButton) {
abrirContratoButton.addEventListener('click', function(event) {
//event.preventDefault();
var firstName = document.getElementById('billing_first_name').value;
var lastName = document.getElementById('billing_last_name').value;
var cpfCnpj = document.getElementById('billing_cpf_cnpj').value;
localStorage.setItem('billing_first_name', firstName);
localStorage.setItem('billing_last_name', lastName);
localStorage.setItem('billing_cpf_cnpj', cpfCnpj);
window.location.href = abrirContratoButton.getAttribute('href');
});
}
});
</script>