Skip to content

Instantly share code, notes, and snippets.

@itzmekhokan
itzmekhokan / country-prefix-billing-phone.php
Created September 3, 2019 18:25
Add country calling code prefix in woocommerce billing phone on change country in checkout
<?php
add_action( 'wp_footer', 'scripts_for_adding_country_prefix_on_billing_phone' );
function scripts_for_adding_country_prefix_on_billing_phone(){
?>
<script type="text/javascript">
( function( $ ) {
$( document.body ).on( 'updated_checkout', function(data) {
var ajax_url = "<?php echo admin_url('admin-ajax.php'); ?>",
country_code = $('#billing_country').val();
var ajax_data = {