Display “In stock” without quantity tracking

Note:

This is a Developer level doc. If you are unfamiliar working with code and resolving potential conflicts, we recommend you work with a Woo Agency Partner for larger projects, or find a WooCommerce developer on Codeable for smaller customizations. We are unable to provide support for customizations under our Support Policy.

By default, WooCommerce does not display “In stock” or the selected stock display format on the product page when the product’s Track stock quantity option is disabled.

Use the woocommerce_get_availability filter to display “In stock” when a product is in stock but WooCommerce is not tracking its quantity.

Add the snippet to your child theme’s functions.php file or use a code snippets plugin. Do not add custom code directly to a parent theme because a theme update will overwrite it.

Before using the snippet, replace your_prefix with a prefix unique to your child theme or custom plugin. Replace your-textdomain with its text domain.

if ( ! function_exists( 'your_prefix_show_in_stock_when_quantity_not_tracked' ) ) {
	/**
	 * Displays "In stock" when a product is in stock but its quantity is not tracked.
	 *
	 * @param string[]   $availability Product availability text and CSS class.
	 * @param WC_Product $product      Product object.
	 * @return string[]
	 */
	function your_prefix_show_in_stock_when_quantity_not_tracked( $availability, $product ) {
		if ( ! $product->managing_stock() && $product->is_in_stock() ) {
			$availability['availability'] = __( 'In stock', 'your-textdomain' );
		}

		return $availability;
	}
}

add_filter( 'woocommerce_get_availability', 'your_prefix_show_in_stock_when_quantity_not_tracked', 10, 2 );

This customization changes only the availability text. It does not enable stock management, change a product’s quantity, or mark an out-of-stock product as in stock.

Use of your personal data
We and our partners process your personal data (such as browsing data, IP Addresses, cookie information, and other unique identifiers) based on your consent and/or our legitimate interest to optimize our website, marketing activities, and your user experience.