WooCommerce: How to Create a New Product Type

Ever wondered how you could add a new product type to WooCommerce admin (on top of the default Simple, Variable, Grouped and External)?

Well, while I was coding this for a client I found a lot of literature online – but nothing really worked for the latest WooCommerce release.

So, here’s the working fix!

Add a custom product type to WooCommerce

PHP Snippet: Create a New Product Type @ WooCommerce Admin

 * @snippet       Create a New Product Type @ WooCommerce Admin
 * @how-to        Watch tutorial @ https://businessbloomer.com/?p=19055
 * @source        https://businessbloomer.com/?p=73644
 * @author        Rodolfo Melogli
 * @compatible    Woo 3.3.3

// --------------------------
// #1 Add New Product Type to Select Dropdown

add_filter( 'product_type_selector', 'bbloomer_add_custom_product_type' );

function bbloomer_add_custom_product_type( $types ){
    $types[ 'custom' ] = 'Custom product';
    return $types;

// --------------------------
// #2 Add New Product Type Class

add_action( 'init', 'bbloomer_create_custom_product_type' );

function bbloomer_create_custom_product_type(){
    class WC_Product_Custom extends WC_Product {
		public function get_type() {
			return 'custom';

// --------------------------
// #3 Load New Product Type Class

add_filter( 'woocommerce_product_class', 'bbloomer_woocommerce_product_class', 10, 2 );

function bbloomer_woocommerce_product_class( $classname, $product_type ) {
    if ( $product_type == 'custom' ) { 
        $classname = 'WC_Product_Custom';
    return $classname;

When should you use a Custom Product Type?

A fan asked this in the comments, so I thought of adding this additional section. The question is: why and when should you use a custom WooCommerce product type?

Well, first of all, the answer is already there. I’m sure you’ve used “WooCommerce Subscriptions” or “WooCommerce Product Bundles” plugins before, and probably noticed that on top of the default Simple, Variable, Grouped and External product type they add their own.

Indeed, the need of using a custom product type comes when you require so much customization that there’s no point in customizing a “Simple” product type for example. In this case, you’d better create your own custom type (mostly if you plan on using this for many products and not just one and let the user play with the product settings).

Finally, having a custom product type allows the user to control its settings. For example, you could create a custom product type that has a checkbox to hide prices and shows a contact form instead. Or a custom product type called “rental”, where it charges a deposit instead of its full price.

Basically, you can do almost anything and creating a custom post type allows you to add options, dropdowns, checkboxes in the Product Edit page so that the user can access them there.

Where to add this snippet?

You can place PHP snippets at the bottom of your child theme functions.php file (before "?>" if you have it). CSS, on the other hand, goes in your child theme style.css file. Make sure you know what you are doing when editing such files - if you need more guidance, please take a look at my free video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything worked as expected. I would be happy to revise the snippet if you report otherwise (please provide screenshots). I have tested this code with Storefront theme, the WooCommerce version listed above and a WordPress-friendly hosting on PHP 7+.

If you think this code saved you time & money, please join other Business Bloomer supporters and avail of 365 days of WooCommerce benefits. Thank you in advance :)

Need Help with WooCommerce Customization?

Check out these free video tutorials!

  • how-to-edit-woocommerce-with-php-snippets
  • woocommerce-hooks-add_action-list-visual
  • woocommerce-customize-single-product-page-PHP

Rodolfo Melogli

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as a WooCommerce freelancer since 2011. His goal is to help entrepreneurs and developers overcome their WooCommerce nightmares. Rodolfo loves travelling, chasing tennis & soccer balls and, of course, wood fired oven pizza.

17 thoughts on “WooCommerce: How to Create a New Product Type

  1. Well Described Rodolfo Melogli ๐Ÿ™‚ Excellent Post!

    1. Thank you ๐Ÿ™‚

  2. Very well described! Rodolfo Melogli.. Adding one para over external/affiliate products will be excellent.. but you did a fantastic job! thanks for information.

    1. Cheers ๐Ÿ™‚

  3. Thanks for this! Is there an easy way to display the product type on the order details area and email?

    1. Hey Aaron – thanks so much for your comment! Yes, this is possible – but unfortunately this is custom work and I cannot provide a complementary solution here via the blog comments. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding! ~R

  4. Hi Rodolfo,

    I am using your code because I have hidden the Add To Cart button for all Simple Products (stupid client request… Don’t ask.), but there is a selection of products that should have an Add To Cart Button… It seems to work when I go to create a product, except 1) the General tab disappears when I select the Custom product type, so I can’t set a price, and 2) Publishing or Updating the product makes it revert back to Simple… See screenshot: https://i.imgur.com/MSb9Y47.png

    1. Hey Joe, thanks for your comment! There is additional PHP to add if you want the custom type to show the Add to Cart etc., but unfortunately this is not part of this post. In regard to the other issue, try updating your PHP, it could be because of that ๐Ÿ™‚

    2. I’m actually having the exact same issue. I’m using PHP 7.1.7, WordPress 4.9.6 and WooCommerce 3.4.1.

      Any recommendation?

  5. Hey Rodolfo,

    Thank you for giving us so much ideas. One question: if I want to delete a product type to clean things up, how can I do that? Or it’s not recommended to delete them?

    1. Sure Peter, you can just “unset” an existing type by using the same filter: “product_type_selector” ๐Ÿ™‚

  6. Where is the code for the WC_Product_Custom class?

    1. Hey Damien, it’s inside this function: bbloomer_create_custom_product_type()

  7. As usual nice to learn from your posts. I spent my days on developing new ideas for plugins and better performance and you help me a lot by sharing. Request: how to move the coupon field in checkout after summary of products instead of on top. This item has never been publiced by anyone yet.

    1. Thank you Pascal ๐Ÿ™‚

  8. Nice post. Can you give an example of why a new custom product would be needed? Aside from subscriptions, the simple, grouped, bundled products are all Iโ€™ve ever seen use cases for.

    1. Jonathan, thanks for your comment and good point! I’m just about to add a new paragraph to the tutorial that should help you with that ๐Ÿ™‚

Questions? Feedback? Support? Leave your Comment Now!

If you are writing code, please wrap it between: [php]code_here[/php]. Failure to complying with this (as well as going off topic) will result in comment deletion. You should expect a reply in about a week - this is a popular blog but I need to get paid work done first. Please consider joining #BloomerArmada to ask me 1-to-1 WooCommerce questions. Thank you :)

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.