• I am trying to add a VAT field to the Customer Billing Address, while this works on the Checkout page with the following code:

    // Company Name Required
    add_filter('woocommerce_checkout_fields','custom_override_checkout_fields');
    function custom_override_checkout_fields($fields){
        $fields['billing']['billing_company']['required'] = true;
        $fields['billing']['billing_vat'] = array(
        'label'       => __('VAT Number','woocommerce'),
        'placeholder' => _x('Enter VAT Number','placeholder','woocommerce'),
        'required'    => true,
        'class'       => array('form-row-wide'),
        'clear'       => true
        );
        return $fields;
    }
    //Display field value on the order edit page
    add_action('woocommerce_admin_order_data_after_shipping_address','my_custom_checkout_field_display_admin_order_meta',10,1);
    function my_custom_checkout_field_display_admin_order_meta($order){
        echo '<p><strong>'.__('VAT Number').':</strong> ' . get_post_meta($order->id,'_billing_vat',true) . '</p>';
    }
    //Order the fields
    add_filter("woocommerce_checkout_fields","order_fields");
    function order_fields($fields){
        $order = array(
            "billing_first_name",
            "billing_last_name",
            "billing_company",
            "billing_vat",
            "billing_country",
            "billing_city",
            "billing_postcode",
            "billing_state",
            "billing_address_1",
            "billing_address_2",
            "billing_email",
            "billing_phone",
        );
    foreach($order as $field){$ordered_fields[$field] = $fields["billing"][$field];}
    $fields["billing"] = $ordered_fields;
    return $fields;
    }

    I also require it to be set on the Customer Billing Address in the account options. As I require to link this to the registration page as I’d like the users to register with all their credentials including the VAT number they own for a B2B Webstore.

    Does anyone know or could anyone point me in the right direction how I would perform this task of not only showing those billing fields of the VAT number on the checkout page but also on the users profile page, as well as how to add all these fields on the registration page?

    Thanks in advance for any assistance for this case!

Viewing 1 replies (of 1 total)
  • i’ve been fighting this for a few days now. i just can’t get the vat value to show in the order page nor mail for that mather…
    i have it on the users profile page and on the registration page. have you done it or do you still need help? because i could send you the code i have.

Viewing 1 replies (of 1 total)
  • The topic ‘WooCommerce Customer Billing Address’ is closed to new replies.