# Show "From" Price Instead of a Price Range

> Replaces price ranges like "$10 - $40" on variable products with a shorter "From $10", which reads better on shop pages.

- Type: PHP
- Runs: Run everywhere
- Category: [WooCommerce](https://wpide.com/library/category/woocommerce/)
- Requires: WooCommerce
- Tags: woocommerce, price, variable-products
- Author: WPIDE Team
- Installs: 0
- Updated: 2026-10-28
- Page: https://wpide.com/library/woo-variable-price-from/

## Code

```php
add_filter( 'woocommerce_variable_price_html', function ( $html, $product ) {
    $prefix = 'From'; // Text shown before the lowest price.

    $min = $product->get_variation_price( 'min', true );
    $max = $product->get_variation_price( 'max', true );

    if ( '' === $min || $min === $max ) {
        return $html;
    }

    return sprintf( '<span class="wpide-from">%s</span> %s', esc_html( $prefix ), wc_price( $min ) . $product->get_price_suffix() );
}, 10, 2 );
```

## Notes

When all variations cost the same, the normal single price is shown.

## How to use it

Install the free WPIDE plugin (https://wordpress.org/plugins/wpide/), find "Show "From" Price Instead of a Price Range" in its snippet library and add it in one click; or create a new PHP snippet in WPIDE (or any code snippets plugin) and paste the code above. More snippets: https://wpide.com/library/
