Woocommerce es el plugin de WordPress para realizar compras online. Muchos temas traen soporte para él y sus características.

En esta ocasión, queremos que en el listado de productos, no nos muestre que un producto tiene precio variable, sino fijo.

Para ello, editamos el archivo functions.php de nuestro tema activo e incluimos lo siguiente al final del mismo:

add_filter( 'woocommerce_variable_sale_price_html', 'my_variation_price_format', 10, 2 );
 
add_filter( 'woocommerce_variable_price_html', 'my_variation_price_format', 10, 2 );
 
function my_variation_price_format( $price, $product ) {
 
	// Main Price
	$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
	$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 
	// Sale Price
	$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
	sort( $prices );
	$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
 
	if ( $price !== $saleprice ) {
	$price = '<del>' . $saleprice . '</del> <ins>' . $price . '</ins>';
	}
	return $price;
}