Hello,
I am working on WordPress (Woocommerce). There are 2 forms on the checkout page. After checking the chekbox, I am trying to transfer the data from the 2nd form to the first form. Texts are transmitted (eg shiping_adress —-> billing_address) There is no problem. However, I cannot transfer the select option instantaneously. It transfers after refreshing the page. However, I cannot see the change without renewal.
Also html : [Imagebb
As far as I can see it uses the woocommerce select2 library. I wrote a trigger but still couldn’t run it. Can you help me ?
My code’s:
“`
function add_checkout_script() { ?>
<script type=”text/javascript”>
jQuery(document).on(‘change’, ‘#copy_to_billing’, function() {
if(this.checked) {
jQuery(“[name=’billing_address_1′]”).val(jQuery(“[name=’shipping_address_1′]”).val());
jQuery(“[name=’billing_city’]”).filter(“:selected”).val(jQuery(“[name=’shipping_city’]”).filter(“:selected”).val());
jQuery(“[name=’billing_city’]”).trigger(“input”);
}
});
</script>
<input id=”copy_to_billing” type =”checkbox” name=”copy_to_billing”
value =”1″ class=”copy_billing woocommerce-form__input woocommerce-form__input-checkbox input-checkbox”><span><?php esc_html_e( ‘ send’, ‘woocommerce’ ); ?></span>