Wordpress 如何自动填写电子商务结帐地址框

Wordpress 如何自动填写电子商务结帐地址框,wordpress,shipping,Wordpress,Shipping,这里是Woocomece新手, 我知道一定有解决办法,但我就是找不到。 我希望当用户进入结帐页面时,他们可以单击按钮或选中某个预定义地址的复选框,它将自动将地址填入发货地址框。 也就是说,用户点击后,它会自动填写表单,其中包含纽约市123街11111号 有人知道怎么做吗 谢谢!本 好吧,我解决了这个问题(有点) 在购物车和结帐页面:因为我认为我不太了解WooCommerce,所以我改变了它,所以现在我有了一个装运区USA和whithin,我有两种装运类型,免费装运和到任何其他地方的统一费率 在签

这里是Woocomece新手,
我知道一定有解决办法,但我就是找不到。
我希望当用户进入结帐页面时,他们可以单击按钮或选中某个预定义地址的复选框,它将自动将地址填入发货地址框。

也就是说,用户点击后,它会自动填写表单,其中包含纽约市123街11111号

有人知道怎么做吗

谢谢!本

好吧,我解决了这个问题(有点)

  • 在购物车和结帐页面:因为我认为我不太了解WooCommerce,所以我改变了它,所以现在我有了一个装运区USA和whithin,我有两种装运类型,免费装运和到任何其他地方的统一费率

  • 在签出页面上,我设置了一个自定义Javascript,当您单击按钮时,它会自动填充其中的地址

  • 在myfunctions.php中

    add_action('woocommerce_before_checkout_form','wnd_checkout_message',10)

    函数wnd\u checkout\u消息(){
    echo“发送到X”配送是免费的!单击此处配送
    ';
    然后在我的实际结账页面上,我有一个JavaScript:

    <script>
    function changeShippingAddr(){
    document.getElementById("shipping_first_name").value = document.getElementById("billing_first_name").value;
    document.getElementById("shipping_last_name").value = document.getElementById("billing_last_name").value;
    document.getElementById("shipping_company").value = "COMPANY";
    document.getElementById("shipping_country").value = "COUNTRY";
    jQuery('body').trigger('update_checkout');
    document.getElementById("shipping_state").value = "STATE";
    jQuery('body').trigger('update_checkout');
    document.getElementById("shipping_address_1").value = "ADDR";
    document.getElementById("shipping_city").value = "CITY";
    document.getElementById("shipping_postcode").value = "ZIP";
    jQuery('body').trigger('update_checkout');
    document.getElementById("select2-shipping_state-container").innerHTML= "State Name";
    }
    </script>
    
    
    函数changeShippingAddr(){
    document.getElementById(“发货名”).value=document.getElementById(“账单名”).value;
    document.getElementById(“shipping_last_name”).value=document.getElementById(“billing_last_name”).value;
    document.getElementById(“装运公司”).value=“公司”;
    document.getElementById(“装运国”).value=“国家”;
    jQuery('body')。触发器('update_checkout');
    document.getElementById(“装运状态”).value=“状态”;
    jQuery('body')。触发器('update_checkout');
    document.getElementById(“发货地址1”).value=“地址”;
    document.getElementById(“shipping_city”).value=“city”;
    document.getElementById(“shipping_postcode”).value=“ZIP”;
    jQuery('body')。触发器('update_checkout');
    document.getElementById(“select2-shipping\u state-container”).innerHTML=“state Name”;
    }
    
    它基本上设置了从账单到发货的名称,并插入了一个默认地址,这样您就不需要输入它了


    感谢所有帮助!

    WC应该自动填写返回客户以前使用过的地址。否则,如果客户是第一次或客人,系统将不会自动填写任何数据。
    <script>
    function changeShippingAddr(){
    document.getElementById("shipping_first_name").value = document.getElementById("billing_first_name").value;
    document.getElementById("shipping_last_name").value = document.getElementById("billing_last_name").value;
    document.getElementById("shipping_company").value = "COMPANY";
    document.getElementById("shipping_country").value = "COUNTRY";
    jQuery('body').trigger('update_checkout');
    document.getElementById("shipping_state").value = "STATE";
    jQuery('body').trigger('update_checkout');
    document.getElementById("shipping_address_1").value = "ADDR";
    document.getElementById("shipping_city").value = "CITY";
    document.getElementById("shipping_postcode").value = "ZIP";
    jQuery('body').trigger('update_checkout');
    document.getElementById("select2-shipping_state-container").innerHTML= "State Name";
    }
    </script>