{"id":3516,"date":"2022-05-09T20:24:24","date_gmt":"2022-05-09T20:24:24","guid":{"rendered":"https:\/\/scriptfeeds.com\/blog\/?p=3516"},"modified":"2022-12-06T21:57:44","modified_gmt":"2022-12-06T21:57:44","slug":"add-gst-vat-number-box-on-woocommerce-checkout-page-and-invoice-without-plugin","status":"publish","type":"post","link":"https:\/\/scriptfeeds.com\/blog\/wordpress\/add-gst-vat-number-box-on-woocommerce-checkout-page-and-invoice-without-plugin\/","title":{"rendered":"Add GST\/VAT number box on WooCommerce checkout page without Plugin"},"content":{"rendered":"\n<p>Customers can be of two types either standard or business one. Standard customer selling process run smoothly using WooCommerce standard features but if the customer is of business type then Seller has to take their GST\/VAT number to generate TAX invoice. <\/p>\n\n\n\n<p>This blog helps you to tackle the problem of entering GST\/VAT number on checkout page for business customer without plugin. There are many plugins which can do it but we strongly recommend using hooks code instead of plugin (Well there are many reasons for it). If you want to know how to ADD <a href=\"https:\/\/scriptfeeds.com\/blog\/wordpress\/gst-billing-in-woocommerce\/\">GST BILLING<\/a> on your WooCommerce store then <a href=\"https:\/\/scriptfeeds.com\/blog\/wordpress\/gst-billing-in-woocommerce\/\">click here<\/a><\/p>\n\n\n\n<h2 class=\"has-medium-font-size wp-block-heading\">This task contain three parts as below:<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>GST\/VAT number box in WooCommerce Checkout page<\/li>\n\n\n\n<li>Showing GST\/VAT number in WooCommerce Admin on order page<\/li>\n\n\n\n<li>Showing GST\/VAT number in WooCommerce processing emails<\/li>\n<\/ul>\n\n\n\n<p>So lets do the above point one by one.<\/p>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\">GST\/VAT number box in WooCommerce Checkout page<\/h3>\n\n\n\n<p>Add the below code on your functions.php file of child theme.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\nadd_action( 'woocommerce_after_order_notes', 'wc_vat_field' );\n\/**\n* GST\/VAT Number in WooCommerce Checkout\n*\/\nfunction wc_vat_field( $checkout ) {\n    echo '&lt;div id=\"wc_vat_field\"&gt;&lt;h2&gt;' . __('GST\/VAT Number') . '&lt;\/h2&gt;';\n    \n    woocommerce_form_field( 'vat_number', array(\n        'type'          =&gt; 'text',\n        'class'         =&gt; array( 'vat-number-field form-row-wide') ,\n        'label'         =&gt; __( 'GST\/VAT Number' ),\n        'placeholder'   =&gt; __( 'Enter your GST\/VAT number' ),\n    ), $checkout-&gt;get_value( 'vat_number' ));\n    \n    echo '&lt;\/div&gt;';\n}<\/code><\/pre>\n\n\n\n<p>Once you added the above code, add the below code just after the above code. We are doing this to save the GST\/VAT number which customer added in box.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action( 'woocommerce_checkout_update_order_meta', 'wc_checkout_vat_number_update_order_meta' );\n\/**\n* Save GST\/VAT Number in the order meta\n*\/\nfunction wc_checkout_vat_number_update_order_meta( $order_id ) {\n    if ( ! empty( $_POST&#91;'vat_number'] ) ) {\n        update_post_meta( $order_id, '_vat_number', sanitize_text_field( $_POST&#91;'vat_number'] ) );\n    }\n}<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\">Showing GST\/VAT number in WooCommerce Admin on order page<\/h3>\n\n\n\n<p>Once above task done, now time to show the GST\/VAT number to Admin on order detail page by adding the following code in same functions.php file after above codes.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_action( 'woocommerce_admin_order_data_after_billing_address', 'wc_vat_number_display_admin_order_meta', 10, 1 );\n\/**\n * Display GST\/VAT Number in order edit screen\n *\/\nfunction wc_vat_number_display_admin_order_meta( $order ) {\n    echo '&lt;p&gt;&lt;strong&gt;' . __( 'GST\/VAT Number', 'woocommerce' ) . ':&lt;\/strong&gt; ' . get_post_meta( $order-&gt;id, '_vat_number', true ) . '&lt;\/p&gt;';\n}<\/code><\/pre>\n\n\n\n<h3 class=\"has-medium-font-size wp-block-heading\">Showing GST\/VAT number in WooCommerce processing emails<\/h3>\n\n\n\n<p>Once above task complete, its very important to show the GST\/VAT number which customer provided on checkout page. So we gonna add one more below code to achieve the same in same functions.php file.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>add_filter( 'woocommerce_email_order_meta_keys', 'wc_vat_number_display_email' );\n\/**\n* GST\/VAT Number in emails\n*\/\nfunction wc_vat_number_display_email( $keys ) {\n     $keys&#91;'VAT Number'] = '_vat_number';\n     return $keys;\n}<\/code><\/pre>\n\n\n\n<p>Once you added the above code, GST\/VAT number will also show on emails of WooCommerce. <\/p>\n\n\n\n<p>So that&#8217;s all you need to do to get the GST\/VAT number from business customer and display them in order and emails. <\/p>\n\n\n\n<p>Happy coding!<\/p>\n\n\n<p>[caldera_form id=&#8221;CF60ca2e3ccf64f&#8221;]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Customers can be of two types either standard or business one. Standard customer selling process run smoothly using WooCommerce standard features but if the customer is of business type then Seller has to take their GST\/VAT number to generate TAX invoice. This blog helps you to tackle the problem of entering GST\/VAT number on checkout [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":3393,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"jnews-multi-image_gallery":[],"jnews_single_post":{"subtitle":"","format":"standard","video":"","gallery":"","source_name":"","source_url":"","via_name":"","via_url":"","override_template":"0","override":[{"template":"2","single_blog_custom":"","parallax":"1","fullscreen":"1","layout":"right-sidebar","sidebar":"default-sidebar","second_sidebar":"default-sidebar","sticky_sidebar":"1","share_position":"float","share_float_style":"share-monocrhome","show_share_counter":"1","show_view_counter":"1","show_featured":"1","show_post_meta":"1","show_post_author":"1","show_post_author_image":"1","show_post_date":"1","post_date_format":"default","post_date_format_custom":"Y\/m\/d","show_post_category":"1","show_post_reading_time":"0","post_reading_time_wpm":"300","show_zoom_button":"0","zoom_button_out_step":"2","zoom_button_in_step":"3","show_post_tag":"1","show_prev_next_post":"0","show_popup_post":"0","number_popup_post":"1","show_author_box":"0","show_post_related":"1","show_inline_post_related":"0"}],"override_image_size":"0","image_override":[{"single_post_thumbnail_size":"no-crop","single_post_gallery_size":"crop-500"}],"trending_post":"0","trending_post_position":"meta","trending_post_label":"Trending","sponsored_post":"0","sponsored_post_label":"Sponsored by","sponsored_post_name":"","sponsored_post_url":"","sponsored_post_logo_enable":"0","sponsored_post_logo":"","sponsored_post_desc":"","disable_ad":"0"},"jnews_primary_category":{"id":"","hide":""},"footnotes":""},"categories":[86,75],"tags":[215],"class_list":["post-3516","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-woocommerce","category-wordpress","tag-add-vat-number-box-on-checkout-page-without-plugin"],"_links":{"self":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/comments?post=3516"}],"version-history":[{"count":0,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/posts\/3516\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media\/3393"}],"wp:attachment":[{"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/media?parent=3516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/categories?post=3516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/scriptfeeds.com\/blog\/wp-json\/wp\/v2\/tags?post=3516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}