• Resolved loopforever

    (@loopforever)


    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' );
    • This topic was modified 5 years, 1 month ago by loopforever.
    • This topic was modified 5 years, 1 month ago by loopforever.
Viewing 4 replies - 1 through 4 (of 4 total)
  • Thread Starter loopforever

    (@loopforever)

    Update
    I fixed the second problem. But I’m still working the first one.

    • This reply was modified 5 years, 1 month ago by loopforever.
    • This reply was modified 5 years, 1 month ago by loopforever.
    • This reply was modified 5 years, 1 month ago by loopforever.
    Plugin Support Gabriel – a11n

    (@gabrielfuentes)

    Hi there 👋

    This is a fairly complex development topic. I’m going to leave it open for a bit to see if anyone is able to chime in to help you out.

    I can also recommend the WooCommerce Developer Resources Portal for resources on developing for WooCommerce.

    You can also visit the WooCommerce Facebook group or the #developers channel of the WooCommerce Community Slack. We’re lucky to have a great community of open-source developers for WooCommerce, and many of our developers hang out there, as well.

    Cheers!

    Thread Starter loopforever

    (@loopforever)

    Hello ,
    Thank you for your answer. Yes, I have written to many places but still haven’t found a solution. While all other data is being transferred, dropdown is not transferred instantly, that is, until the page is loaded.
    My search continues. Thanks again.

    Plugin Support slash1andy

    (@slash1andy)

    Automattic Happiness Engineer

    Since there’s not been any further responses, I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘Shipping to a different address problem’ is closed to new replies.