Created
June 4, 2025 14:50
-
-
Save xlplugins/ee758f3ae4ef5e9a096da3ab1dc6235e to your computer and use it in GitHub Desktop.
show customer shipping or billing into checkout fields
This file contains hidden or 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
add_filter( 'woocommerce_form_field_args', function ( $args, $key, $value ) { | |
$args['custom_attributes']['data-profile'] = $value; | |
return $args; | |
}, 20, 3 ); | |
add_action( 'wp_footer', function () { | |
if ( ! is_user_logged_in() ) { | |
return; | |
} | |
?> | |
<script language="JavaScript"> | |
(function ($) { | |
$(document.body).on('change', '#shipping_same_as_billing,.shipping_same_as_billing', function () { | |
setTimeout(() => { | |
$('.wfacp_divider_billing .wfacp-form-control[data-profile]').each(function () { | |
$(this).val($(this).data('profile')); | |
}) | |
}); | |
}) | |
$(document.body).on('change', '#billing_same_as_shipping,.billing_same_as_shipping', function () { | |
setTimeout(() => { | |
$('.wfacp_divider_billing .wfacp-form-control[data-profile]').each(function () { | |
console.log($(this).data('profile')); | |
$(this).val($(this).data('profile')); | |
}) | |
}); | |
}); | |
})(jQuery) | |
</script> | |
<?php | |
}, 100 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment