Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

woocommerce check out field fix, conditional eu vat number and stop rendering op address fields on country change. WordPress

  • SOLVED

Hi,

I am trying to revamp my checkout page in woocommerce. I have done this with a plugin: checkout field editor pro. It works great, though two issues remain, which I would like to get solved.

This is the current checkout page: http://testend.nl/demo1/checkout/?add-to-cart=52700
There is a conditional switch (radio button) that ask the user whether he wants to check out as customer (prive) or business (zakelijk). If checking out as a business more fields show up.

Issues:
1. When selecting a different country than the default country automatically the address fields are prompted. I don't want that. Address fields should only be shown when zakelijk is checked at the radio button. See video for glitch: http://www.screencast.com/t/zWuHt24E3http://www.screencast.com/t/zWuHt24E3

2. I have also added a woocommerce EU vat number field that does a VIES check. It is currently located under the heading "Jouw Account”, the field is called “vat number", however I want to move it. It should be conditonal on the radio button (when zakelijk is selected). Basically I have a field called "btw nummer" at this moment, the "vat number" field should be at exactly that place. Here are two screenshots that illustrate this: https://prntscr.com/hk6mwu , https://prntscr.com/hk6myb.

I can give you admin credentials to our testserver to fix this.

Hope you can help, struggling on this fix.

Kind regards,

Joris

Answers (3)

2017-12-07

Mohamed Ahmed answers:

Hello Soofos,

After we have read your question and watch your video and images, we have understood your requests.

1- Address fields should only be shown when zakelijk is checked at the radio button only not when change the country.

2. If the "prive" radio button is checked, hide "VAT Number" field.

You can send us the login details to our email callmeinstantly #gmail.com to do this easy job.


Soofos comments:

Sent you a request and extra details, hope you can help!


Mohamed Ahmed comments:

We have sent you an email :)


Soofos comments:

Sent you feedback just now.

2017-12-08

Arnav Joy answers:

are you still looking for help ?

2017-12-07

mod mi answers:

Hello,
Possible to have access to check out php code?

Update after checking code:
1.The fields still reappear when you change country because it's a default wc function from the select country code. since you are adding custom fields you can override the default ones. (couldn't make changes in the functions.php file for some reason it doesn't save):


// Hide default checkout fields
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields' );

function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_first_name']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_address_1']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_city']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_country']);
unset($fields['billing']['billing_state']);
unset($fields['billing']['billing_phone']);
unset($fields['order']['order_comments']);
unset($fields['billing']['billing_address_2']);
unset($fields['billing']['billing_postcode']);
unset($fields['billing']['billing_company']);
unset($fields['billing']['billing_last_name']);
unset($fields['billing']['billing_email']);
unset($fields['billing']['billing_city']);
return $fields;
}


2. The BTW number (VAT number) does not appear now when prive is checked.
changed the condition rule that when radio button prive is not checked to hide the field.


Soofos comments:

Yes sure can you send me an email at [email protected], then I will give you access to our test server.