WooCommerce: How to Create a Custom 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        Get CustomizeWoo.com FREE
 * @author        Rodolfo Melogli
 * @compatible    Woo 6
 * @donate $9     https://businessbloomer.com/bloomer-armada/

// --------------------------
// #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;

// --------------------------
// #4 Show Product Data General Tab Prices

add_action( 'woocommerce_product_options_general_product_data', 'bbloomer_custom_product_type_show_price' );

function bbloomer_custom_product_type_show_price() {
	global $product_object;
	if ( $product_object && 'custom' === $product_object->get_type() ) {
		wc_enqueue_js( "
			$('.product_data_tabs .general_tab').addClass('show_if_custom').show();

// --------------------------
// #5 Show Add to Cart Button

add_action( "woocommerce_custom_add_to_cart", function() {
    do_action( 'woocommerce_simple_add_to_cart' );

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 custom code?

You should place PHP snippets at the bottom of your child theme functions.php file and CSS at the bottom of its 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 guide "Should I Add Custom Code Via WP Editor, FTP or Code Snippets?" and my video tutorial "Where to Place WooCommerce Customization?"

Does this snippet (still) work?

Please let me know in the comments if everything went 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.

If you think this code saved you time & money, feel free to join 17,000+ WooCommerce Weekly subscribers for blog post updates and 250+ Business Bloomer supporters for 365 days of WooCommerce benefits. Thank you in advance!

Need Help with WooCommerce?

Check out these free video tutorials. You can learn how to customize WooCommerce without unnecessary plugins, how to properly configure the WooCommerce plugin settings and even how to master WooCommerce troubleshooting in case of a bug!

Rodolfo Melogli

Business Bloomer Founder

Author, WooCommerce expert and WordCamp speaker, Rodolfo has worked as an independent 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.

33 thoughts on “WooCommerce: How to Create a Custom Product Type

  1. Thank you for writing this great code. It really helped me BUT

    This code is not working today 2022-05-17.

    After creating a custom product using this code I expect to be able to buy it in my shop. Actually I cannot buy it in my shop because there is no “add to cart” button. There is “Read more” button.

    The normal cause of this is either the product having no price or being out of stock. My product does have a price and is in stock.

    I have spent several hours trying to guess/Google what additional configuration is necessary but I can’t work it out.

    1. Thank you James. I’ve revised the snippet, section #5 should help you

  2. I’ve created a custom product type for discontinued products, which become unpurchasable with no price, and the product type is working perfectly. Except: It seems to be saving information, like price and stock, if the product was originally a simple product before being changed to a discontinued product. Is there anyway to “clear” the info from other product types for this product when it’s changed to a discontinued product type? I hope that makes sense!

    1. Hello Rachael, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  3. Hi, I can’t set price to the custom product type!! The “General” tab is automatically becoming invisible.

      1. Does this mean part #4 is obsolete and can be removed from this snippet?
        Instead of #4 you use and change the code from the link mentioned?

  4. how do you make the variations work with custom product type? I displayed the “Used for variations” checkbox, checked it, added the variations but it won’t show on single product page..what could be the issue?

    1. Suresh, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  5. Can you please tell me how can I add a product type query filter option or query source to select individual product type in elementor product widget. I mean the products will be shown by choosing product type.

    1. Hi Rafayan, thanks so much for your comment! Yes, this is definitely possible, but I’m afraid it’s custom work. If you’d like to get a quote, feel free to contact me here. Thanks a lot for your understanding!

  6. Hi,

    Thanks for the post. I have one question. If I have to check whether the cart item is the custom product type then will a function like the following work or do I need to write the function?


    Thank you

    1. That won’t work, no

  7. Hi Rodolfo! Thanks for the excellent tutorial! I can see the new product type but not the tabs General and Inventory, so I can not set the price and the stock… What it is missing?

    1. Hi Agostino! The “General” tab is actually there, it’s just hidden. WooCommerce thinks it is a grouped product and displays that as none. You will need custom JS or custom CSS to make them show. Hope this helps

  8. Well Described Rodolfo Melogli 🙂 Excellent Post!

    1. Thank you 🙂

  9. 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 🙂

  10. 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

  11. 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?

  12. 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” 🙂

  13. Where is the code for the WC_Product_Custom class?

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

  14. 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 🙂

  15. 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 shortcodes: [php]code_here[/php]. Failure to complying with this (as well as going off topic, not writing in English, etc.) will result in comment deletion. You should expect a reply in about 2 weeks - this is a popular blog but I need to get paid work done first. Please consider joining BloomerArmada to get blog comment reply priority, ask me 1-to-1 WooCommerce questions and enjoy many more perks. Thank you :)

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