Last active
January 13, 2020 09:10
Example of intl-tel-input initialization on wordpress custom plugin and handling on wc-ajax=checkout_update_order_review
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function init_tel(){ | |
$utils_url = plugins_url('/js/utils.js', __FILE__); | |
?> | |
<script> | |
var input = document.querySelector("#phone"); | |
var iti = window.intlTelInput(input,{ | |
utilsScript: "<?php echo $utils_url; ?>", | |
// the countries at the top of the list. defaults to united states and united kingdom | |
preferredCountries: [ "my", "us", "gb" ], | |
autoPlaceholder: null, | |
separateDialCode: true, | |
hiddenInput: "mobileNo" | |
}); | |
var hiddenInput = document.querySelector('#mobileNo'); | |
hiddenInput.value = "<?php echo $POST["mobileNo"];?>"; | |
</script> | |
<?php | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment