"From" price for products with variations
The "From price" module in Polski for WooCommerce replaces the price range of a variable product (e.g. "19.99 - 49.99 PLN") with one price, "from 19.99 PLN", on shop archives and product pages. It is on by default. It only changes products whose variations have different prices; a variable product where every variation costs the same keeps its normal price.
Why it matters
Section titled "Why it matters"The default WooCommerce price display for products with variations shows the full range: "19.99 PLN - 49.99 PLN". This can be confusing for customers and takes up a lot of space in product listings.
The "from 19.99 PLN" format:
- Is more readable on mobile devices
- Clearly communicates the lowest price
- Is a standard in most online stores
- Works both on archive pages and on the product page
Configuration
Section titled "Configuration"The module is called From Price for Variable Products in Polski > Modules and is enabled on a fresh install. Its settings are in Polski > Settings > Tax & Pricing.
| Setting | Description | Default |
|---|---|---|
| Enable "from" price display | Show "from {price}" instead of a price range | Yes |
| Price text template | Text template with the {price} token |
from {price} |
Both settings are stored in the polski_prices option (from_price_enabled, from_price_text). Turning the module off in Polski > Modules and unticking the setting have the same effect.
Template examples
Section titled "Template examples"| Template | Result |
|---|---|
from {price} |
from 19.99 PLN |
Price from {price} |
Price from 19.99 PLN |
ab {price} |
ab 19.99 PLN (for DE) |
How it works
Section titled "How it works"- The module filters the
woocommerce_get_price_htmlhook - It checks whether the product is a
WC_Product_Variable - It fetches the variation prices for display and checks whether a range exists (min != max)
- If so, it replaces the price range with the "from {lowest_price}" format
- If all variations have the same price, it displays the normal price
What price is shown
Section titled "What price is shown"| Case | Output |
|---|---|
| Variations at 19.99, 29.99 and 49.99 | from 19.99 PLN |
| All variations at 29.99 | The normal WooCommerce price, unchanged |
| The cheapest variation is on sale | from the sale price, with no struck-through regular price |
| Simple, grouped or external product | Unchanged |
The lowest price is the active price of the cheapest variation, taken the way WooCommerce displays it, so it includes or excludes tax according to the shop's display setting. It is formatted with wc_price() in the shop currency.
The output is wrapped in <span class="polski-from-price">, which you can style in your theme.
Filter
Section titled "Filter"polski/price/from_price_html receives the finished HTML and the product. It runs only when the module replaced a range.
// Customize the "from" price HTMLadd_filter('polski/price/from_price_html', function (string $html, WC_Product $product): string { // Add a CSS class or change the format return '<span class="my-from-price">' . $html . '</span>';}, 10, 2);Disabling for selected products
Section titled "Disabling for selected products"To keep the range for specific products, rebuild it in the filter. Do not call $product->get_price_html() here: it runs the same filter again and loops.
add_filter('polski/price/from_price_html', function (string $html, WC_Product $product): string { if ($product->get_id() === 123) { return wc_format_price_range( $product->get_variation_price('min', true), $product->get_variation_price('max', true) ); } return $html;}, 10, 2);Why does one of my variable products still show a price range?
Section titled "Why does one of my variable products still show a price range?"The module needs both switches on: the module in Polski > Modules and "Enable "from" price display" in the settings. It also leaves the range alone when the product is not a WooCommerce variable product.
Does the "from" price include VAT?
Section titled "Does the "from" price include VAT?"It follows WooCommerce's "Display prices in the shop" setting, because the module reads the variation prices the way WooCommerce displays them.
Can I translate the word "from"?
Section titled "Can I translate the word "from"?"Yes. Change the "Price text template" setting, for example to ab {price} or od {price}. Keep the {price} token.