Hi @chefpanda123,
I was thinking about moving the field to the position after the “Password” field and I think the best solution would be to use JavaScript. I could move it there by using WooCommerce hooks, however, then field’s name would change from billing_eu_vat_number
to account_eu_vat_number
, which is not good.
What you need to do is to add just a couple of lines of custom JavaScript code. I would suggest using our small Custom CSS, JS & PHP plugin for that, however, you can also use any other custom JS tool. So if you install the plugin, you need to go to “Tools > Custom CSS, JS & PHP” in your admin dashboard and locate “JS: front-end” option in “JavaScript Options” section. I would also suggest setting position to “Load in footer”. Now there you need to add this code:
jQuery( document ).ready( function() {
if ( jQuery( '#account_password_field' ).length ) {
jQuery( '#billing_eu_vat_number_field' ).detach().insertAfter( jQuery( '#account_password_field' ) );
}
} );
this will move the field right after the password field, so your customers will have to check “Create an account?” checkbox to make this field visible. If you wish EU VAT field to be always visible (i.e. no matter if “Create an account?” checkbox is checked or not), you can move the field outside of password’s “account” section. To do that you need to add this JavaScript code instead:
jQuery( document ).ready( function() {
if ( jQuery( 'div.woocommerce-account-fields' ).length ) {
jQuery( '#billing_eu_vat_number_field' ).detach().insertAfter( jQuery( 'div.woocommerce-account-fields' ) );
}
} );
As for logged users (i.e. those who don’t have “Password” field at all), you can just move it to the bottom of the billing section with the plugin’s “Priority (i.e. position)” option.
Hope that helps and please let me know if that’s good enough or if you have any questions.
P.S. If it was what you needed and you like the plugin, please consider leaving me a rating.
-
This reply was modified 4 years, 12 months ago by Algoritmika.