[email protected]
+(91) 99038 42429
Company Profile
Partner With Us
Indisn Flag
  • About
  • Services
    • Mobile App Development
    • Website Development
    • eCommerce Development
    • Digital Marketing
  • Products
    • Salesform CRM App

      Salesform CRM App

      Manage leads, automate follow-ups, and track performance using smart dashboards.

      Salesform CRM App
    • Learning Management System

      Learning Management System

      Teach your students on any topic anywhere anytime

      Learning Management System
    • Directory Listing Website

      Directory Listing Website

      Create a powerful business directory with search, location filters, and review options — ideal for service providers, real estate, and local businesses.

      Directory Listing Website
    • Matrimonial App Solution

      Matrimonial App Solution

      Match verified profiles of brides and grooms using intelligent filters and tailored recommendations.

      Matrimonial App Solution
    • Cab Booking App

      Cab Booking App

      Empower your taxi business with real-time tracking, driver assignment, and fare calculation. Includes customer app, driver app, and admin panel.

      Cab Booking App
    • News Portal System

      News Portal System

      Build your online newspaper or magazine with multi-author support, category-based news feeds, and instant publishing tools.

      News Portal System
    • Loyalty Rewards App

      Loyalty Rewards App

      Digitize customer loyalty with QR code-based rewards, brand offers, and redemption dashboards for retailers and electricians.

      Loyalty Rewards App
    • Logistics Management Platform

      Logistics Management Platform

      A modern logistics platform that simplifies requirement creation, bidding, driver assignment, and order handling.

      Logistics Management Platform
    • Theatre Booking Platform

      Theatre Booking Platform

      Built for luxury and high-end entertainment providers, this ready-to-deploy solution allows you to offer a premium sanctuary for birthdays, anniversaries, and romance.

      Logistics Management Platform
  • Portfolio
  • Case Study
    • Ganashakti News Portal
    • Pradhan Mantri Ujjwala Yojana
    • Cab Booking Application
    • Logistics Bidding Platform
    • Real Estate Platform
  • Blogs
  • Learn With Us
  • Career
  • Contact Us
  • About
  • Services
    • Mobile App Development
    • Website Development
    • eCommerce Development
    • Digital Marketing
  • Products
    • Salesform CRM App

      Salesform CRM App

      Manage leads, automate follow-ups, and track performance using smart dashboards.

      Salesform CRM App
    • Learning Management System

      Learning Management System

      Teach your students on any topic anywhere anytime

      Learning Management System
    • Directory Listing Website

      Directory Listing Website

      Create a powerful business directory with search, location filters, and review options — ideal for service providers, real estate, and local businesses.

      Directory Listing Website
    • Matrimonial App Solution

      Matrimonial App Solution

      Match verified profiles of brides and grooms using intelligent filters and tailored recommendations.

      Matrimonial App Solution
    • Cab Booking App

      Cab Booking App

      Empower your taxi business with real-time tracking, driver assignment, and fare calculation. Includes customer app, driver app, and admin panel.

      Cab Booking App
    • News Portal System

      News Portal System

      Build your online newspaper or magazine with multi-author support, category-based news feeds, and instant publishing tools.

      News Portal System
    • Loyalty Rewards App

      Loyalty Rewards App

      Digitize customer loyalty with QR code-based rewards, brand offers, and redemption dashboards for retailers and electricians.

      Loyalty Rewards App
    • Logistics Management Platform

      Logistics Management Platform

      A modern logistics platform that simplifies requirement creation, bidding, driver assignment, and order handling.

      Logistics Management Platform
    • Theatre Booking Platform

      Theatre Booking Platform

      Built for luxury and high-end entertainment providers, this ready-to-deploy solution allows you to offer a premium sanctuary for birthdays, anniversaries, and romance.

      Logistics Management Platform
  • Portfolio
  • Case Study
    • Ganashakti News Portal
    • Pradhan Mantri Ujjwala Yojana
    • Cab Booking Application
    • Logistics Bidding Platform
    • Real Estate Platform
  • Blogs
  • Learn With Us
  • Career
  • Contact Us
  • About
  • Services
    • Mobile App Development
    • Website Development
    • eCommerce Development
    • Digital Marketing
  • Products
    • Salesform CRM App
    • Learning Management System
    • Directory Listing Website
    • Matrimonial App Solution
    • Cab Booking App
    • News Portal System
    • Loyalty Rewards App
    • Logistics Management Platform
    • Theatre Booking Platform
  • Portfolio
  • Case Study
    • Ganashakti News Portal
    • Pradhan Mantri Ujjwala Yojana
    • Cab Booking Application
    • Logistics Bidding Platform
    • Real Estate Platform
  • Career
  • Blogs
  • Contact Us
  • Partner With Us
  • About
  • Services
    • Mobile App Development
    • Website Development
    • eCommerce Development
    • Digital Marketing
  • Products
    • Salesform CRM App
    • Learning Management System
    • Directory Listing Website
    • Matrimonial App Solution
    • Cab Booking App
    • News Portal System
    • Loyalty Rewards App
    • Logistics Management Platform
    • Theatre Booking Platform
  • Portfolio
  • Case Study
    • Ganashakti News Portal
    • Pradhan Mantri Ujjwala Yojana
    • Cab Booking Application
    • Logistics Bidding Platform
    • Real Estate Platform
  • Career
  • Blogs
  • Contact Us
  • Partner With Us

How to Add HSN Code/ Number to Your Woocommerce Products? Simple and Variable Products Both

Updated at: March 26, 2024

What is an HSN Code/ Number?

HSN (Harmonized System of Nomenclature) Code or HSN Number is the Category Identification Number of a certain good. Indian Government tracks the sale and consumption of different commodities through HSN number only.

Why is it Important to have HSN Code in Your Woocommerce Products?

According to Indian Taxation Laws, it is mandatory for all businesses to display HSN Code for each product on their Tax Invoice. So if you are generating and printing your invoice through Woocommerce itself (which most of us do) whether a code or plugin; then you need this field in your products data to be able to display HSN Code in front of each product.

If you are just starting out and just need to create an invoice then you can try this free online invoice generator. If you’re printing your invoice through your Accounting Software, and that takes care of your HSN needs, then you need HSN Code configured in your Accounting Software and there will be no need to replicate the same data on your Woocommerce products also. So you can stop reading further, chill back and enjoy.

But if you’re one of us who is printing the Invoices directly through Woocommerce, then you can read on and learn how to deal with this problem effectively.

Get your HSN Code added with the help of the experts. Click here for assistance.

Why Doesn’t Woocommerce Give the HSN Code Option by Default?

With such a big Indian customer base using Woocommerce as their choice of Ecommerce Platform, you can expect Woocommerce to be a little more considerate towards entrepreneurs without IT background setting up our Ecommerce Website. However on the other hand Woocommerce is so customizable and gives so many options to their users to configure according to their usage, that it is hardly fair to be blaming Woocommerce for it.

Woocommerce gives an identification number by default which is SKU (Stock Keeping Unit). Apart from that, even GTIN (Global Trade Identification Number) can be inserted into products with the use of Default Woocommerce features or plugins.
However, there is hardly any plugin or code available on the internet which solves the plight of adding HSN Code to Woocommerce Products of Indian Businesses.

We went through a similar phase of total confusion to totally organized about our HSN Code Requirements and below we are mentioning the different ways through which anybody can add HSN Code to their Woocommerce Products, even YOU with no IT Background.

Adding HSN Code to Woocommerce Products:

There are 2 ways of entering HSN Code to your Woocommerce Products (simple or variable or mix).

First one is the easy way, where we add HSN Code attribute to our products and assign the values to it.

Second one, is a little bit tougher where we add the HSN Code by adding a custom field to our products. We do this by adding code to our Child Theme.

Although Second way is a little complex, it is the anatomically correct method, because HSN is not an attribute of a given product but rather is an identification number. So in a lot of ways, HSN Code is not very different to SKU with the exception of that SKUs are not supposed to be duplicate between any two given product. Whereas the HSN Code is mostly similar among many products in a category, but changes when the category of the product changes.

Adding HSN Code seems highly technical? Get help from the experts. Contact us for assistance.

Wondering what simple, variable or variation products are? Click here

Adding HSN Code Through Attributes – The Easy Way!

Who Can Use This Method?

  • If you only have simple products on your website.
  • If you only have variable products; Where HSN Code remains same among variations of a variable product
  • If you have a mix of simple and variable products; Where HSN Code remains same among variations of a variable product.

Adding HSN Code Through Attributes

This is the easier method, where we can make a global attribute ‘HSN Code’ and add different values to it.

You can make Global attributes in Woocommerce by going to Products > Attributes.

1 1

Write the Attribute Name as ‘HSN Code’ and click Add attribute.

Now when you’re editing or adding a new product, you can add HSN Code in the attributes section of the product. Write the 8 or 4 letter HSN Code in Value of the attribute ‘HSN Code’.

2

After you’re done assigning HSN Code Values to all your products. You can start using the value of this attribute to print in the invoice in front of the product.

Wondering what is a good PDF Invoicing plugin for Woocommerce? We recommend ‘Booster for Woocommerce’.
It has over 100 modules of different useful features and its
customisability according to usage is extraordinary. It is a must have for any Woocommerce Store.

Important Points to Remember:

  • Through this method, different HSN Code can be assigned to different simple products.
  • All the variations share the attribute of its parent variable product. So HSN Code will be same for all the variations inside a Variable Product.
  • Most sites can use this method even with a mix of simple and variable products in their store.

Adding HSN Code through Code or Programmatically – The Coding Way!

Who can Use this Method?

  • If you have only variable products, but HSN changes among some of the variations of the same product.
  • If you have only simple products. You can assign HSN Code to each product separately.
  • If you have a mix of simple and variable products, but HSN changes among some of the variations of the same product.

Eg: In an Electrical Industry 10A, 25A, 50A, 100A, 200A of a product has HSN Code 8536 since it comes under Domestic, but 250A, 300A, 400A and 500A of the same product has HSN Code 8538 since this comes under Industrial.

Adding HSN Code through Code or Programmatically:

This second method is the anatomically correct method, and this will give fewer problems in the long term. Since Woocommerce is so customizable, we are going to be adding a custom field to our Product Data and we are going to name this field as ‘HSN Code’. We will have to write separate code as to how the simple products will save the ‘HSN Code’ meta field, and how variable products will be saving their ‘HSN Code’ meta field.

Place the below PHP snippets at the bottom of your child theme’s functions.php file

For Simple Product

1. Add Custom Field Input

add_action( 'woocommerce_product_options_pricing', 'custom_add_hsn_to_products' ); function custom_add_hsn_to_products() { woocommerce_wp_text_input( array( 'id' => 'hsn_code', 'placeholder' => __( 'Enter 8-digit HSN No. here', 'woocommerce' ), 'class' => 'short wc_input_price', 'label' => __( 'HSN Code', 'woocommerce' ), )); }

2. Save HSN Field

add_action( 'save_post_product', 'custom_save_hsn' ); function custom_save_hsn( $product_id ) { global $pagenow, $typenow; if ( 'post.php' !== $pagenow || 'product' !== $typenow ) return; if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) return; if ( isset( $_POST['hsn_code'] ) ) { if ( $_POST['hsn_code'] ) update_post_meta( $product_id, 'hsn_code', $_POST['hsn_code'] ); } else delete_post_meta( $product_id, 'hsn_code' ); }

For Variable Products

1. Add Custom Field Input

add_action( 'woocommerce_variation_options_pricing', 'custom_add_hsn_to_variations', 10, 3 ); function custom_add_hsn_to_variations( $loop, $variation_data, $variation ) { woocommerce_wp_text_input( array( 'id' => 'hsn_code[' . $loop . ']', 'placeholder' => __( 'Enter 8-digit HSN No. here', 'woocommerce' ), 'class' => 'short', 'label' => __( 'HSN Code', 'woocommerce' ), 'value' => get_post_meta( $variation->ID, 'hsn_code', true ) ) ); }

2. Save Custom Field on Product Variation

add_action( 'woocommerce_save_product_variation', 'custom_save_hsn_variations', 10, 2 ); function custom_save_hsn_variations( $variation_id, $i ) { $hsn_code = $_POST['hsn_code'][$i]; if ( isset( $hsn_code ) ) update_post_meta ( $variation_id, 'hsn_code', esc_attr( $hsn_code ) ); }

3. Store Custom Field Value into Variation Data

add_filter( 'woocommerce_available_variation', 'custom_add_hsn_variation_data' ); function custom_add_hsn_variation_data( $variations ) { $variations['hsn_code'] = '<div class="woocommerce_custom_field">Custom Field: <span>' . get_post_meta( $variations[ 'variation_id' ], 'hsn_code', true ) . '</span></div>'; return $variations; }

After you’re done with the above, when you go to Add/ Edit a product in WordPress – Woocommerce, you will see a new Field available where we can update the HSN Code.

In Simple Products, you can find the HSN Code Metafield in General tab of Product Data. Something like this:

3

In Variable Products, you can see the ‘HSN Code’ field in the variations tab of Product Data.

Here you can add HSN Value to each Variation individually.

4

Wondering if you can change the input type or location of the meta-field in Woocommerce? Yes, you can as Woocommerce is very customizable. Click Here to learn.

Eg: What if instead of a Text field, you want to give only dropdown of choices or want only numbers as input.

Want a more technical walkthrough of the above process with more customizable options. Click Here to learn

After the above process is done, you can use PDF Invoicing Plugin to use the metafield _hsn_code to display HSN Values next to the product.

Important Points to Remember:

  • Always try to add the code to your Child Theme Functions.php file. To avoid any change in the file upon updating the Theme.
  • You will be able to add HSN Code value individually to each Variation of a Variable Product. Separate HSN Code Value for different simple products is also possible.

If you don’t want to go through the entire trouble and need help in implementing this for your website, feel free to get in touch with us.

E-Commerce Website Development Cost in India in 2023PrevE-Commerce Website Development Cost in India in 2023April 19, 2021
Top 10 Website Design Companies in Kolkata in [year] (Updated)May 17, 2021 Top 10 Website Design Companies in Kolkata in [year] (Updated) Next

Comment (01)

  1. ZaDeveloper
    January 6, 2024

    Thank you for being generous and sharing this Custom Field code… worked like a charm…
    Would be great to also have the add HSN Code Bulk Edit Feature for Product Variations.

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts

Woocommerce

How to Add HSN Code/ Number to Your Woocommerce Products? Simple and Variable Products Both

What is an HSN Code/ Number? HSN (Harmonized System of Nomenclature) Code or...

Rumpa Naskar April 20, 2021
Web DesignWoocommerce

Shopify vs WooCommerce: Best One to Choose in 2023

The advantages of having an eCommerce website for your business are enormous. You...

Rumpa Naskar June 8, 2022
Share

Innovination Logo

We are one of the leading web design & digital marketing agency in India providing customized solutions to our clients as per their requirement. We have worked with more than 300 customers and have maintained our rating of 4.8 star on Google since our inception.
Services
Website Development
Web Applications
Mobile Applications
Quick Links
Home
Blog
Partner With Us
Address
Address: 281, SK Deb Rd, Block E, Lake Town, Kolkata, West Bengal 700048
Cashfree Payment Logo
DigitalOcean Payment Logo
Shiprocket Payment Logo
Phone & Email
Phone: +(91) 99038 42429
Email: [email protected]
Follow Us

Copyright 2020, Innovination | All Rights Reserved.

Privacy Policy

WhatsApp us