Home > Back-end >  Transfer Billing State to Shipping State
Transfer Billing State to Shipping State

Time:10-06

I am working on an e-commerce site that works with Woocommerce. On the Checkout page, I'm trying to import the data I get from the Billing Details into the Shipping Details. I have defined a checkbox for this. By ticking the checkbox, the data is transferred. So far, no problem.

I can transfer data such as First Name, Last Name. But unfortunately I can't pass State (selected value). The problem arises probably because it is a select box. However, I couldn't find the problem. Below is the jQuery code I wrote for this. I'll be glad if it helps.

jQuery("[name='billing_state']").filter(":selected").val(jQuery("[name='shipping_state']").filter(":selected").val());

CodePudding user response:

Try the code below, this works for me with the default theme "Twenty Twenty-One".

Billing state to Shipping state:

jQuery("[name='shipping_state']").val(jQuery("[name='billing_state']").val()).change();

Shipping state to Billing state:

jQuery("[name='billing_state']").val(jQuery("[name='shipping_state']").val()).change();
  • Related