Add VAT field to checkout billing fields

This topic has 4 replies, 3 voices, and was last updated 3 months, 1 weeks ago ago by Andrew Mitchell

  • Avatar: Riaan
    Riaan
    Participant
    April 19, 2024 at 14:02

    Hi there,

    Im trying to customize the checkout billing fields by adding a VAT field after company field. Tested the code on a different theme and its working but not on XStoretheme. I cant seem to override the fields. Below is the part of code im trying in child theme functions.php (I know how to handle validation and saving).

    add_action( 'woocommerce_before_order_notes', 'add_vat_checkout_field' );
    function add_vat_checkout_field( $checkout ) { 
       $current_user = wp_get_current_user();
       $saved_vat_no = $current_user->vat_no;
       woocommerce_form_field( 'vat_no', array(        
          'type' => 'text',        
          'label' => 'VAT Number',        
          'placeholder' => '12345678',        
          'required' => true,        
          'default' => $saved_vat_no,        
       ), $checkout->get_value( 'vat_no' ) ); 
    }
    3 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    April 19, 2024 at 16:46

    Hi @Riaan,

    The code is working fine at our local sites: https://prnt.sc/0-RU89i29tob

    Could you please provide temporary wp-admin access?

    To grant WP-Admin access, please proceed to create a new user account with an administrator role through your WordPress Dashboard. Once the account is established, you may securely transmit the username and password to us via the Private Content section designated for this purpose.

    Thank you for your cooperation and we look forward to hearing from you soon.

    Best Regards,
    8Theme’s Team

    Avatar: Riaan
    Riaan
    Participant
    April 19, 2024 at 22:18

    Thanks, I have figured it out. Its working now.

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    April 19, 2024 at 22:18

    Dear Riaan,

    We hope you’re reveling in the experience our theme brings! Your enthusiasm is what fuels our passion. Would you be so kind as to channel that energy into a 5-star rating on ThemeForest? Your feedback is the spark that lights our way!

    Click here to spread the love: https://themeforest.net/downloads

    Thank you for being an integral part of our journey!

    Best Regards,
    The 8Theme Team

  • Viewing 4 results - 1 through 4 (of 4 total)

The issue related to '‘Add VAT field to checkout billing fields’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.