Skip to content
Site Under Re-Design: We're updating & improving the docs! Some layouts or content may look broken or inconsistent during this process. If you’re unable to find an article, please use the search bar while we restructure and optimize the sidebar navigation.

Snippet: Change Price for WooCommerce Out of Stock Products

function myprefix_edit_woo_price( $price, $product ) {
	if ( ! $product->is_in_stock() ) {
		$price = 'Sold';
	}
	return $price;
}

add_filter( 'woocommerce_variable_sale_price_html', 'myprefix_edit_woo_price', 10, 2);
add_filter( 'woocommerce_variable_price_html', 'myprefix_edit_woo_price', 10, 2);
add_filter( 'woocommerce_get_price_html', 'myprefix_edit_woo_price', 10, 2);
All PHP snippets should be added via child theme's functions.php file or via a plugin.
We recommend Code Snippets (100% Free) or WPCode (sponsored)
Back To Top