Skip to content

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