/**
 * Display variation product starting price instead of range.
 *
 * @param string     $price   Variation product price range.
 * @param WC_Product $product Current product.
 *
 * @return string
 */
function dorzki_display_variation_starting_price( $price, $product ) {

	$prices = $product->get_variation_prices();
	$starting_price = current( $prices['price'] );

	return sprintf( __( 'Price starts at %s', 'dorzki' ), wc_price( $starting_price ) );

}

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

How to use it?

Usually adding functionality to a WordPress site is by creating a plugin.
However you can simply copy the code and paste it in your child theme’s functions.php file at the end of the file, just before ?>.

For JavaScript code you will need to add them to your theme’s main JavaScript file.

Having issues with the code?

If the code doesn’t work or you get an error please let us know in the comments section.
We will do our best to fix it as-soon-as-possible and update the code on this page.

Comments

  1. Ahmed

    Amazing, thanks!

    Reply

Leave a Reply