Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save Ephemerich/cd4c8ec76844ea1126cfbf4c2ec0ae4f to your computer and use it in GitHub Desktop.

Select an option

Save Ephemerich/cd4c8ec76844ea1126cfbf4c2ec0ae4f to your computer and use it in GitHub Desktop.
<?php
add_action('wp_footer', function(){
if(!function_exists('is_checkout') || !is_checkout()) {
return;
}
?>
<script>
(function($){
var $doc = $(document);
var $body = $('body');
$doc.ready(function(){
function updateBillingPostCode(e){
var $this = $(this);
var value = $this.val();
// console.log(value);
var $target = $('#billing_postcode');
if($target.length > 0) {
$target.val(value);
$body.trigger('update_checkout');
}
}
$doc.on('change', '#billing_address_type', updateBillingPostCode);
});
})(jQuery);
</script>
<?php
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment