Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Aelia EU VAT Assistant for WooCommerce - Show VAT number only when the company field is populated.
- *
- * Last updated: 5 August 2019
- *
- * HOW TO USE THIS CODE
- * Simply add the code to the bottom of your theme's functions.php file, and it
- * will run automatically. For more information: https://www.skyverge.com/blog/add-custom-code-to-wordpress/
- *
- * GPL DISCLAIMER
- * Because this code program is free of charge, there is no warranty for it, to the extent permitted by applicable law.
- * Except when otherwise stated in writing the copyright holders and/or other parties provide the program "as is"
- * without warranty of any kind, either expressed or implied, including, but not limited to, the implied warranties of
- * merchantability and fitness for a particular purpose. The entire risk as to the quality and performance of the program
- * is with you. should the program prove defective, you assume the cost of all necessary servicing, repair or correction.
- *
- * Need a consultation, or assistance to customise this code? Find us on Codeable: https://aelia.co/hire_us
- */
- add_action('wp_footer', function() {
- ?>
- <script type="text/javascript">
- jQuery(document).ready(function($) {
- $('form.checkout, #order_review').on('change', function() {
- var company_field_empty = ($('#billing_company').val().trim() == '');
- // Check if the company field is populated. If not, hide the VAT number
- // field.
- $('.aelia_wc_eu_vat_assistant.vat_number').toggle(!company_field_empty);
- // Uncomment the code below to clear the VAT number when the company
- // name is emptied
- //if(company_field_empty) {
- // $('#vat_number').val('');
- //}
- });
- });
- </script>
- <?php
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement