Expert Woocommerce developer for function.php
- or -
Post a project like this1742
$10
- Posted:
- Proposals: 5
- Remote
- #2443009
- PRE-FUNDED
- Completed
Description
Experience Level: Entry
Target: We need VAT number field under Customer Billing Address. While creating a manual order need to populate that VAT number under Billing.
We got the VAT field showing up by copying below code to function.php. Reff: Screenshot_1.jpeg
add_filter('woocommerce_customer_meta_fields','add_custom_meta_field');
function add_custom_meta_field($fields){ $fieldData = array('label' => 'VAT Number'); $fields['billing']['fields']['billing_vat'] = $fieldData; return $fields; }
Code found here: https://stackoverflow.com/questions/43335335/woocommerce-customer-billing-address
We also got the label showing up in new orders billing by copying below code to function.php. Reff: Capture.JPG
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 ); function my_custom_checkout_field_display_admin_order_meta($order){ echo ''.__('Custom field title').':get_id(), '_shipping_custom_field', true ) . ''; }
Code found here: https://stackoverflow.com/questions/42341548/add-a-custom-field-to-woocommerce-billing-form
Now, the issue:
When we select from the customer from the list, it populates the billing address but not the VAT number. We need that user-specific VAT number here to show up here and ready for an invoice. Reff: Expecting.JPG
We need this VAT to be present in the invoice(email or print), along with the remaining billing address.
We got the VAT field showing up by copying below code to function.php. Reff: Screenshot_1.jpeg
add_filter('woocommerce_customer_meta_fields','add_custom_meta_field');
function add_custom_meta_field($fields){ $fieldData = array('label' => 'VAT Number'); $fields['billing']['fields']['billing_vat'] = $fieldData; return $fields; }
Code found here: https://stackoverflow.com/questions/43335335/woocommerce-customer-billing-address
We also got the label showing up in new orders billing by copying below code to function.php. Reff: Capture.JPG
add_action( 'woocommerce_admin_order_data_after_billing_address', 'my_custom_checkout_field_display_admin_order_meta', 10, 1 ); function my_custom_checkout_field_display_admin_order_meta($order){ echo ''.__('Custom field title').':get_id(), '_shipping_custom_field', true ) . ''; }
Code found here: https://stackoverflow.com/questions/42341548/add-a-custom-field-to-woocommerce-billing-form
Now, the issue:
When we select from the customer from the list, it populates the billing address but not the VAT number. We need that user-specific VAT number here to show up here and ready for an invoice. Reff: Expecting.JPG
We need this VAT to be present in the invoice(email or print), along with the remaining billing address.
Tolstoy B.
100% (5)Projects Completed
5
Freelancers worked with
3
Projects awarded
33%
Last project
18 Sep 2022
India
New Proposal
Login to your account and send a proposal now to get this project.
Log inClarification Board Ask a Question
-
There are no clarification messages.
We collect cookies to enable the proper functioning and security of our website, and to enhance your experience. By clicking on 'Accept All Cookies', you consent to the use of these cookies. You can change your 'Cookies Settings' at any time. For more information, please read ourCookie Policy
Cookie Settings
Accept All Cookies