Uncategorized

How to Build Custom WooCommerce Product Types Beyond Simple and Variable

How to register a custom WooCommerce product type: extend WC_Product, add it to product_type_selector, map the class, add a data tab, save fields and print the add to cart form. Checked against WooCommerce 11.3.0 on 15 November 2026.

·14 min read
WooCommerce product type dropdown with a custom Rental product option expanding into a Rental tab with price and days fields

To create a custom product type in WooCommerce, you write a class that extends WC_Product, add the type to the product_type_selector filter, map the type name to your class with woocommerce_product_class, and add whatever admin fields and front-end output the type needs. WooCommerce then stores the type as a term in the product_type taxonomy and loads your class every time it builds a product of that type. We checked every hook and signature below against the WooCommerce source and docs on 15 November 2026, at version 11.3.0, the current release on WordPress.org.

One note on how we tested. The code in this guide was checked line by line against the WooCommerce trunk source and the hook docs, and it follows the same patterns the core types use. We did not run it on a live store for this refresh, so treat it as a verified starting point and run it on staging before you ship it.

How do I create a custom product type in WooCommerce?

Build one plugin with six moving parts. We use a Rental type as the running example because it needs its own price meaning (a price per period), its own admin field (the period length) and a changed buy button, which is the usual reason to leave the built-in types.

  1. Load a class that extends WC_Product after WooCommerce has loaded, and return your type slug from get_type().
  2. Register the label so the type shows in the product type dropdown, using product_type_selector.
  3. Map slug to class with woocommerce_product_class, so WooCommerce builds your object instead of falling back to a simple product.
  4. Add admin fields through woocommerce_product_data_tabs and woocommerce_product_data_panels.
  5. Save the fields on woocommerce_admin_process_product_object, which runs just before the product is saved.
  6. Print the buy button on woocommerce_{type}_add_to_cart, which the single product page fires for the current type.

That is the whole contract. Everything else (REST output, block themes, variations, a custom data store) is optional and covered further down, with notes on when you can skip it.

What product types does WooCommerce ship with?

WooCommerce core ships four types in the product type dropdown: simple, grouped, external/affiliate and variable. You can see this list in wc_get_product_types(), which is the function that feeds the dropdown. A fifth value, variation, exists for the child products of a variable product, but it is never something a merchant picks directly.

Two things that people often call product types are not types at all. Virtual and downloadable are checkboxes on a simple product, defined by the product_type_options filter. Subscriptions, bookings, bundles and similar products come from extensions, and those extensions register their own types through the exact same product_type_selector filter you are about to use. Older articles, including an earlier version of this one, list six built-in types. That count mixed in a checkbox and an extension, so we corrected it.

Type

Slug

What it is for

Where it comes from

Simple product

simple

One item, one price, optional stock

Core

Grouped product

grouped

A page that lists several simple products

Core

External/Affiliate product

external

A product sold on another site, with a custom button

Core

Variable product

variable

One product with attribute-based variations

Core

Variation

variation

A single variation of a variable product

Core, not selectable

Subscription, bundle, booking and others

varies

Recurring billing, fixed kits, date-based slots

Extensions that register their own type

We checked the list in wc_get_product_types() and the ProductType enum in the WooCommerce source on 15 November 2026.

Where does WooCommerce store the product type?

WooCommerce stores the product type as a term in the product_type taxonomy, attached to the product post. It is not saved in a _product_type post meta field, which is a common guess from people who look in the wrong table. The terms are plain slugs such as simple, grouped, external and variable, and your custom type adds one more term the first time a product is saved with it.

You can see the read path in the product data store: get_product_type() loads the product’s terms from product_type and returns the first term name, or simple if there is none. The write path is wp_set_object_terms() with the new type, followed by the woocommerce_product_type_changed action. Because the type lives in a taxonomy, wc_get_products( array( 'type' => 'rental' ) ) can filter by it with an ordinary tax query.

A quick debugging check follows from this. If a product behaves like a simple product after saving, look at the term first. A right term means the class mapping is the problem, and a wrong term means the type was missing from the selector when the form was posted.

One side effect matters before you ship. When the class does not exist, WC_Product_Factory::get_product_classname() falls back to WC_Product_Simple. If a customer deactivates your plugin, existing rental products keep their term but behave as simple products, and saving one from the admin form would store it as simple. List the affected products before you remove a type from a live store.

Do I need a custom product type, or will attributes and add-ons do?

Build a custom type only when the product needs different admin fields, different price logic or a different purchase flow from every built-in type. If the difference is a choice the shopper makes (size, engraving text, a gift wrap option), a variation or an add-on is cheaper to build and easier to maintain. Custom types also carry a long-term cost: every WooCommerce release is another chance for a hook to change, and a type that nobody tests breaks quietly.

What you need

Better fit

Why

Shopper picks size, colour or material, each with its own stock

Variable product with attributes

Core handles stock and price per variation. See our guide to ordering product attributes.

Shopper adds an option that changes the price (engraving, gift wrap, extra licence)

A product add-ons plugin

Fields and price rules are configured in the admin, no code. Our add-ons roundup compares them, and WooCommerce.com sells an official Product Add-Ons extension.

Several existing products sold together on one page

Grouped product

Built in, no code.

Fixed kit sold as one item, or date-based slots

An existing bundle or booking extension

Mature plugins already solve availability and reporting. WooCommerce.com lists WooCommerce Bookings.

Rentals with date ranges and deposits

A rental plugin first

Our rental plugin roundup covers the ready-made options.

One simple field shown on the product page

Product meta or an attribute

No new type needed.

Different admin fields, own price meaning and own buy flow, for a catalogue you control

Custom product type

This is the case this guide covers.

A useful test: write down the three things that must differ from a simple product. If all three are display changes, use a template or a hook on a simple product. If at least one is a data model or purchase-flow change, a type earns its place. Teams that build marketplaces, rental stores or digital-licence shops usually hit that bar, and we cover the neighbouring decision of a full plugin in our post on whether you need a custom extension or an add-on.

Does this work in the new product editor?

The classic product data box is now the only product editor, and the hooks in this guide are the supported way to extend it. WooCommerce experimented with a block-based product editor for several releases. The extension APIs for it were deprecated in WooCommerce 10.9.0, and the editor itself was removed in WooCommerce 11.0.0 with no replacement, according to the README the WooCommerce team left in the repository for the remaining compatibility classes. The removal pull request, Remove deprecated product block editor, was merged in June 2026.

The practical effect for a custom type is good news. You do not need a block template, a registered product-editor block or a second code path. Tutorials from 2024 and 2025 that tell you to register blocks for the new product form describe an API that no longer exists, so do not copy them. If you inherit a plugin that references those classes, it loads only because of the compatibility shims, and those shims are marked as temporary.

Step 1: Load the class at the right time

Define your product class only after WooCommerce has loaded, because WC_Product does not exist before that. The cleanest hook is woocommerce_loaded, which WooCommerce fires from its plugins_loaded handler once every plugin has been included. Put the class in its own file and require it from that hook. This is the most common failure we see in forum threads: the code is registered from a theme setup function or a late hook, the class is not defined when the first product loads, and WooCommerce quietly builds a simple product instead.

<?php
/**
 * Plugin Name:       WCD Rental Product Type
 * Description:       Example custom product type, "Rental".
 * Requires Plugins:  woocommerce
 * Version:           1.0.0
 */

defined( 'ABSPATH' ) || exit;

// Load the class once WooCommerce (and so WC_Product) exists.
add_action(
	'woocommerce_loaded',
	static function (): void {
		require_once __DIR__ . '/class-wcd-product-rental.php';
	}
);

Step 2: Write the product class

The class extends WC_Product and answers one question the core cannot guess: what is my type called? Override get_type() and return the slug. Everything else (price, stock, tax, images) is inherited, because WooCommerce stores those through the generic product data store.

<?php
// class-wcd-product-rental.php
defined( 'ABSPATH' ) || exit;

class WCD_Product_Rental extends WC_Product {

	/**
	 * The slug stored in the product_type taxonomy.
	 */
	public function get_type() {
		return 'rental';
	}

	/**
	 * Days covered by one unit of the price. Stored as post meta.
	 */
	public function get_rental_period_days( $context = 'view' ) {
		return max( 1, absint( $this->get_meta( '_wcd_rental_period_days', true, $context ) ) );
	}

	/**
	 * Button label on the single product page.
	 */
	public function single_add_to_cart_text() {
		return apply_filters(
			'woocommerce_product_single_add_to_cart_text',
			__( 'Rent now', 'wcd-rental' ),
			$this
		);
	}
}

If your type should never need shipping, override is_virtual() to return true. needs_shipping() in the core class is just the opposite of is_virtual() passed through a filter, so one override covers the cart, the checkout and the shipping calculator. We left it out of the example because rentals of physical goods often do ship.

Step 3: Add the type to the selector

The product_type_selector filter receives the slug-to-label array that wc_get_product_types() builds, and the product data box turns every entry into an option in the dropdown. Add your type and return the array. Register this filter on every request, not only in the admin. The REST API builds its allowed type list from the same function, so a filter wrapped in is_admin() makes REST requests fail with an invalid type error.

add_filter(
	'product_type_selector',
	static function ( array $types ): array {
		$types['rental'] = __( 'Rental product', 'wcd-rental' );
		return $types;
	}
);

Step 4: Map the type to your class

WC_Product_Factory::get_product_classname() turns a type slug into a class name and runs the result through the woocommerce_product_class filter. By default the name is WC_Product_ followed by the slug with each hyphen-separated word capitalised, so rental would look for WC_Product_Rental. That naming convention is for core classes. A plugin should use its own prefix and map it explicitly, which avoids a clash if WooCommerce ever ships a class with the same name.

add_filter(
	'woocommerce_product_class',
	static function ( $classname, $product_type ) {
		return 'rental' === $product_type ? WCD_Product_Rental::class : $classname;
	},
	10,
	2
);

The filter passes four arguments: the class name, the type slug, the post type (product or product_variation) and the product ID. We only need the first two. If the returned class does not exist, the factory falls back to WC_Product_Simple, which is exactly the silent failure described in the mistakes box below.

Step 5: Add a Rental tab to the product data box

A data tab needs two pieces: an entry in woocommerce_product_data_tabs that draws the tab link, and a panel printed on woocommerce_product_data_panels that holds the fields. Give the tab the class show_if_rental so the product data script shows it only when Rental is selected. The tab’s target must equal the ID of your panel.

add_filter(
	'woocommerce_product_data_tabs',
	static function ( array $tabs ): array {
		$tabs['wcd_rental'] = array(
			'label'    => __( 'Rental', 'wcd-rental' ),
			'target'   => 'wcd_rental_data',
			'class'    => array( 'show_if_rental' ),
			'priority' => 25,
		);
		return $tabs;
	}
);

add_action(
	'woocommerce_product_data_panels',
	static function (): void {
		global $product_object;
		?>
		<div id="wcd_rental_data" class="panel woocommerce_options_panel hidden">
			<div class="options_group">
				<?php
				woocommerce_wp_text_input(
					array(
						'id'          => '_wcd_rental_price',
						/* translators: %s: currency symbol */
						'label'       => sprintf( __( 'Price per period (%s)', 'wcd-rental' ), get_woocommerce_currency_symbol() ),
						'data_type'   => 'price',
						'desc_tip'    => true,
						'description' => __( 'Charged once for each rental period in the cart.', 'wcd-rental' ),
					),
					$product_object
				);

				woocommerce_wp_text_input(
					array(
						'id'                => '_wcd_rental_period_days',
						'label'             => __( 'Days per period', 'wcd-rental' ),
						'type'              => 'number',
						'desc_tip'          => true,
						'description'       => __( 'Length of one rental period.', 'wcd-rental' ),
						'custom_attributes' => array(
							'min'  => '1',
							'step' => '1',
						),
					),
					$product_object
				);
				?>
			</div>
		</div>
		<?php
	}
);

We added our own price field instead of reusing the General tab. The General tab’s pricing group carries the show_if_simple and show_if_external classes, so it stays hidden for a custom type unless you add show_if_rental to it from JavaScript. That script approach is what older answers recommend, and it has a timing problem: the admin script decides what to show when the page loads, so a class added later is ignored until the dropdown changes. A dedicated panel with its own fields avoids the whole issue. The hidden core price field still posts with the form, and Step 6 overrides it.

Step 6: Save the fields

Hook woocommerce_admin_process_product_object. WooCommerce fires it after it has copied the posted values onto the product object and before it calls save(), so you set properties on the object and let the core do a single save. That is better than the older woocommerce_process_product_meta_{type} action, which still exists but runs after the save and encourages a second write per request. WooCommerce already verified the nonce and the user’s capability by the time this action runs.

add_action(
	'woocommerce_admin_process_product_object',
	static function ( WC_Product $product ): void {
		if ( ! $product instanceof WCD_Product_Rental ) {
			return;
		}

		// phpcs:disable WordPress.Security.NonceVerification.Missing -- WooCommerce verifies the nonce and capability before this action.
		$price  = isset( $_POST['_wcd_rental_price'] )
			? wc_format_decimal( wc_clean( wp_unslash( $_POST['_wcd_rental_price'] ) ) )
			: '';
		$period = isset( $_POST['_wcd_rental_period_days'] )
			? max( 1, absint( wp_unslash( $_POST['_wcd_rental_period_days'] ) ) )
			: 1;
		// phpcs:enable WordPress.Security.NonceVerification.Missing

		// The core stores the active price in _price when regular price changes.
		$product->set_regular_price( $price );
		$product->update_meta_data( '_wcd_rental_price', $price );
		$product->update_meta_data( '_wcd_rental_period_days', $period );
	}
);

Setting the regular price is what makes the product purchasable. is_purchasable() requires a non-empty price, and the data store copies the regular price into the _price field that the shop, search and sorting use. We keep a separate _wcd_rental_price meta only so the panel can show the value back without reading the core field. If you skip that, read $product->get_regular_price() in the panel and pass it as the field’s value.

Step 7: Print the add to cart form

The single product page calls woocommerce_template_single_add_to_cart(), which fires do_action( 'woocommerce_' . $product->get_type() . '_add_to_cart' ). Core types hook their own templates onto that action: woocommerce_simple_add_to_cart loads single-product/add-to-cart/simple.php, and the variable, grouped and external types do the same with their own files. For a custom type you attach your own callback to woocommerce_rental_add_to_cart.

For our rental example the simple form is exactly right. The quantity box becomes the number of rental periods, the price is per period, and the cart already multiplies them. So we reuse the core function and add a price suffix that says what one unit covers.

// Reuse the core simple-product form (price check, stock, quantity, button).
add_action( 'woocommerce_rental_add_to_cart', 'woocommerce_simple_add_to_cart' );

// Show what one unit of the price covers.
add_filter(
	'woocommerce_get_price_html',
	static function ( $price_html, $product ) {
		if ( ! $product instanceof WCD_Product_Rental || '' === $product->get_price() ) {
			return $price_html;
		}

		$days = $product->get_rental_period_days();

		return $price_html . ' <small class="wcd-rental-period">' . esc_html(
			sprintf(
				/* translators: %d: number of days */
				_n( 'per %d day', 'per %d days', $days, 'wcd-rental' ),
				$days
			)
		) . '</small>';
	},
	10,
	2
);

When you need a different form (a date picker, a seat selector, extra required inputs), copy the pattern: print your own <form class="cart"> with a submit button named add-to-cart and the product ID as its value, as simple.php does. If the submit handler needs special logic, WooCommerce lets you take over with woocommerce_add_to_cart_handler_rental. The form handler checks has_action() for that name, and when it finds one it calls your action instead of the built-in simple handler, so you are then responsible for validating the request and adding the item to the cart.

What happens on block themes and the block add to cart?

A custom type still renders on a block theme, through a fallback. The Add to Cart with Options block loads a block template part for the four core types. For any other type it looks for an experimental filter, and when nothing supplies a template it calls the same woocommerce_{type}_add_to_cart action your classic code already uses. So the hook from Step 7 keeps working, and the block wraps your output in its own container and adds quantity stepper behaviour when it finds a visible quantity input.

Two limits are worth planning around. First, you cannot yet design a per-type layout in the Site Editor for a custom type, because the block ships templates only for the core types. A request for per-type templates has been open on GitHub since 2023. Second, the block’s interactivity is built around its own template parts, so a heavily custom JavaScript form is safest when it works from your printed markup and does not assume the block’s internals. We checked this fallback in the block’s PHP render code on 15 November 2026.

Does the REST API accept a custom product type?

Yes, once the type is in the selector. In the current WooCommerce controllers, the type parameter’s allowed values are built from array_keys( wc_get_product_types() ), which is the array your product_type_selector filter extends. A 2021 GitHub report showed the REST API rejecting a custom auction type with a message listing only the four core types, and a likely cause on a custom store is a selector filter that runs only in the admin. Register it on every request and the type appears in the allowed list.

A product created through the API still goes through the product class, so a REST-created rental has the right get_type(), but it has none of the meta your admin form saves. Write the period and price through the product’s meta data in the same request, or add a short REST field for them. Our guide to custom WooCommerce REST endpoints shows how to expose extra product data cleanly.

Do I need a custom data store for a new type?

Almost never. The product constructor asks for a data store named product- plus the type, and the data store loader falls back to the plain product store when no specific one is registered. That default store reads and writes standard product fields and any meta you add through the CRUD methods. A custom store, registered with the woocommerce_data_stores filter, only pays off when you need a custom table for query speed, and then you also own migrations, multisite and cleanup.

There is a reason to resist overriding store internals even then. In June 2026 a trunk change to how the product store creates products was flagged in review because it would have bypassed subclasses that override update_post_meta(), and the change was reverted. The lesson holds for any plugin: extend through the public CRUD methods and hooks, and avoid overriding protected store methods that WooCommerce may reorganise.

Can a custom product type have variations?

Yes, but it takes extra work, and WooCommerce does not treat custom types as variable by default. The Attributes tab has a Used for variations checkbox, and a 2023 change made it depend on a class that marks which types can use variations. That change briefly disabled the checkbox for variable-like extension types until the core was patched. If your type needs variations, test the Attributes tab with a real product before you build on it, and consider whether a plain variable product with an add-on would do the job instead.

How do I test a new product type?

Test the full path, not only the admin screen. We use this short checklist for every type we ship:

  • Create a product, pick Rental in the dropdown, fill the tab, save, and confirm the product_type term and both meta rows in the database.
  • Reload the edit screen and confirm the dropdown, tab and fields show the saved values. A tab that vanishes after save usually means the type was not in the selector on the second request.
  • Open the product page on a classic theme and a block theme and confirm the price suffix, quantity box and button label.
  • Add to cart, change the quantity, and confirm the line total on the cart and checkout pages.
  • Create a product through the REST API with type set to rental and confirm it is accepted.
  • Deactivate the plugin on staging and confirm what happens to existing rental products, so you know the cleanup plan.

Common mistakes people report

We read the WooCommerce issue tracker on 15 November 2026 for recurring custom product type problems. These are the ones that keep coming back, paraphrased, with the issue linked so you can read the original thread.

  • The type silently saves as a simple product. One developer in issue 20322 (2018) registered the class, selector and class filter, and still got a simple product. The cause was where the code ran: registration inside a theme framework’s setup function instead of a normal early hook. The factory falls back to WC_Product_Simple whenever your class is missing, so load it from woocommerce_loaded as in Step 1.
  • The price or General tab fields do not show. Reports in issue 16580 (2017) and issue 15732 (2017) describe pricing fields staying hidden for a custom type. The core fields carry show_if_simple style classes, and adding show_if_yourtype from late JavaScript does not run in time. Use your own panel as in Step 5.
  • The REST API rejects the type. Issue 29823 (2021) shows a 400 error that listed only simple, grouped, external and variable. The allowed list comes from the selector filter, so register that filter on every request, not only in is_admin().
  • Expecting a per-type layout on block themes. Issue 54434 (closed January 2025) added the fallback that renders the PHP add to cart hook for third-party types, and issue 38203 is still open as a request for per-type templates. Build the form on the woocommerce_{type}_add_to_cart hook and do not depend on a Site Editor template per type.
  • Variations checkbox disabled on variable-like types. Issue 39490 (2023) followed a core change that disabled the Used for variations checkbox for extension types until it was patched. Test the Attributes tab on every WooCommerce major release if your type uses variations.
  • Following a block-editor tutorial. Guides written for the block-based product editor do not apply, because that editor was removed in WooCommerce 11.0.0 (pull request 65500). The classic hooks in this guide are the supported route.

Checked on 15 November 2026. The older issues are closed, but their causes still match what we see in current code, which is why we list them.

When should we build this instead of a plugin?

Buy a plugin when your need matches a documented feature, such as bookings, bundles or add-ons, because the vendor carries the maintenance. Build a custom type when your catalogue behaves in a way no extension models: a licence product with its own delivery rules, a rental with deposit logic tied to your own stock system, or an industrial product with a private pricing grid. In those cases a small, well-tested type in your own plugin is easier to keep stable than several extensions bent into shape.

Frequently asked questions

What are the default WooCommerce product types?

Simple, grouped, external/affiliate and variable. The variation type exists for child products of variable products, and virtual or downloadable are checkboxes rather than types.

Is the product type stored in post meta?

No. It is stored as a term in the product_type taxonomy. The data store reads the first term name and returns simple when there is none.

Does a custom product type work with the Cart and Checkout blocks?

The Cart and Checkout blocks read cart items through WooCommerce’s own cart, so a custom type that adds normal items works as long as it is purchasable. Test any custom cart item data on the blocks, since they use the Store API rather than the classic form fields.

Do products break if I remove the plugin that registers the type?

They keep their product_type term, but WooCommerce falls back to WC_Product_Simple when the class is missing, so they behave as simple products and your custom data is ignored. Plan a migration before you uninstall.

Is there still a new product editor I need to support?

No. The block-based product editor was removed in WooCommerce 11.0.0, so the classic product data box is the only editor to support.

Sources we checked

All checked on 15 November 2026 against WooCommerce 11.3.0, the version listed on WordPress.org.

Part of the Wbcom Designs family

The all-in-one WordPress community stack

Also ours: wbcomdesigns.comvapvarun.combrndle.com