Skip to content

Instantly share code, notes, and snippets.

@aliaramli
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
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