WooCommerce Variable Product show lowest Price

Posted on January 15, 2015

In WooCommerce you can create products with multiple variations, i.e. colors, sizes etc.. You can create custom variations through the product features tab when editing a product.

WooCommerce shows the lowest through the highest price, when you want to show only the lowest price, you can use this code in a (custom) plugin.

Before:

low-high -- small

 

 

 

 

After:

low-only -- small

 

 
 

 

Add this code into an existing (and activated) plugin or create a custom plugin file and activate the plugin in the WordPress Plugin page.

add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2);

function custom_variation_price( $price, $product ) {

	$price = '';

	if ( !$product->min_variation_price || 
              $product->min_variation_price !== $product->max_variation_price ) {
		$price .= '<span class="from">' . _x('From', 'min_price', 'woocommerce') . ' </span>';
		$price .= woocommerce_price($product->get_price());
	}

	return $price;
}

No Replies to "WooCommerce Variable Product show lowest Price"