Shipping to a different address problem
-
Hello,
I’m trying to do an operation like here. But I want to do the opposite. I made a change for billing_city. because it was not working.
i want to, if the customer says “Ship to a different address?” clicks, a new form opens. Fills this form. Later, if it checks the “Send” checkbox, all values are recorded in Billing details.
There are two problems here.
1-) Province is not transferred instantly. So, after refreshing the page, it appears in the Billing details section. As far as I can see it is using the select2 library. I typed a trigger but it doesn’t work. What can I do for it ?2-) I want that if the client says “Ship to a different address?” When you select (checked) “Send” checkbox appears. So, the checkbox should be hidden initially. I have written many jqueries linked to ship_to_different_address (Ship to a different address? name). However, these do not work. Can you help me ?
thild theme/function.php
function add_checkout_script() { ?> <script type="text/javascript"> jQuery(document).on('change', '#copy_to_billing', function() { if(this.checked) { jQuery("[name='billing_first_name']").val(jQuery("[name='shipping_first_name']").val()); jQuery("[name='billing_last_name']").val(jQuery("[name='shipping_last_name']").val()); jQuery("[name='billing_address_1']").val(jQuery("[name='shipping_address_1']").val()); jQuery("[name='billing_address_2']").val(jQuery("[name='shipping_address_2']").val()); jQuery("[name='billing_city']").filter(":selected").val(jQuery("[name='shipping_city']").filter(":selected").val()); jQuery("[name='billing_state']").val(jQuery("[name='shipping_state']").val()); jQuery("[name='billing_phone']").val(jQuery("[name='shipping_phone']").val()); jQuery("[name='billing_country']").val(jQuery("[name='shipping_country']").val()); } }); </script> <input id="copy_to_billing" type ="checkbox" name="copy_to_billing" class="transfer-to-billing" value ="1" class="copy_billing woocommerce-form__input woocommerce-form__input-checkbox input-checkbox"><span class="transfer-to-billing"><?php esc_html_e( ' Send', 'woocommerce' ); ?></span> <?php } add_action( 'woocommerce_after_checkout_form', 'add_checkout_script' );
The topic ‘Shipping to a different address problem’ is closed to new replies.