Add text before or after the price in WooCommerce
Add a prefix or suffix to WooCommerce prices with the built-in suffix setting or a safe filter, and why Cart and Checkout blocks need another approach.
At a glance
To show text such as From before a price or incl. VAT after it, WooCommerce has a Price display suffix setting that needs no code. For anything else use the woocommerce_get_price_html filter and escape what you output. Cart and Checkout built with blocks do not use the classic PHP filters, so they need the suffix setting, the Store API or the classic shortcodes. This guide covers each case.
Updated November 29, 2026 · For WooCommerce store owners and developers
- For store owners and developers adding a prefix or suffix to prices
- No code WooCommerce, Settings, Tax, Price display suffix (needs taxes enabled)
- Code the woocommerce_get_price_html filter for product pages and loops
- Classic cart the woocommerce_cart_item_price filter, which takes three arguments
- Cart and Checkout blocks classic filters may not apply; use the suffix setting or the Store API
- Safe working use a small plugin or child theme, never edit WooCommerce or the parent theme
On this page
You may want "From" before a price, "incl. VAT" after it, or "per month" on a subscription. For a suffix, WooCommerce has a setting that needs no code. For anything else, use the `woocommerce_get_price_html` filter and escape what you output. Cart and checkout pages built with blocks need extra care, covered below.
Which method should I use?
| Where the text should appear | Method |
|---|---|
| After the price, about tax | Price display suffix setting |
| Product page, shop and category loops | woocommerce_get_price_html filter |
| Classic cart line items | woocommerce_cart_item_price filter |
| Cart and Checkout blocks | Suffix setting, Store API extension, or classic shortcodes |
Can I add a suffix without code?
Yes. Open WooCommerce, Settings, Tax and find Price display suffix. Type text such as inc. VAT or per item. It also accepts {price_including_tax} and {price_excluding_tax}, so you can show "(12.00 excluding tax)". It follows each product's tax status, so use it first when the label is about tax. It appears only when taxes are enabled in Settings, General; without tax, use the filter.
How do I add a prefix or suffix with code?
The filter receives the price markup and the product. Return the changed markup:
add_filter( 'woocommerce_get_price_html', function ( $price_html, $product ) {
if ( '' === $price_html ) {
return $price_html;
}
$prefix = '<span class="price-prefix">' . esc_html__( 'From', 'my-shop' ) . '</span> ';
$suffix = ' <span class="price-suffix">' . esc_html__( 'per licence', 'my-shop' ) . '</span>';
return $prefix . $price_html . $suffix;
}, 10, 2 );Place it in a small plugin or a child theme. esc_html__ outputs translatable, escaped text. The empty-price check prevents "From per licence" on products with no price. The default priority of 10 is fine; the old habit of 999 is rarely needed. To limit the text to certain products, test the product inside the filter, for example to affect only a category:
if ( ! has_term( 'software', 'product_cat', $product->get_id() ) ) {
return $price_html;
}For variable products, $product->get_id() is the parent ID, which is what you want for category checks. Use $product->is_type( 'variable' ) to change the label only for ranges, for instance "From" only when prices differ.
What about the classic cart and checkout?
woocommerce_get_price_html covers the product page, loops, related products and anywhere a theme prints $product->get_price_html(), including our price shortcode. It does not cover the line items in the cart table or checkout summary. On the classic shortcode-based cart a different filter controls the line price, passing three arguments (price, cart item array, cart item key), not the product:
add_filter( 'woocommerce_cart_item_price', function ( $price, $cart_item, $cart_item_key ) {
return $price . ' <span class="price-suffix">' . esc_html__( 'per licence', 'my-shop' ) . '</span>';
}, 10, 3 );Older tutorials often pass one callback to both filters with two arguments, which sends the wrong data type into the cart one. Use a separate function per filter. The subtotal column, order emails and invoices have their own filters, such as woocommerce_cart_item_subtotal; add them only if you need them, and test an email as well.
What about the Cart and Checkout blocks?
Since WooCommerce 8.3, new stores use the Cart and Checkout blocks by default. These are rendered by React in the browser from the Store API, not through the PHP template filters, so the classic filter may not change them.
Use the Price display suffix setting, which many block layouts respect.
Modify the Store API response from PHP with woocommerce_store_api_register_endpoint_data and render the data in a small block extension. This is a developer task.
Switch the page back to the classic Cart or Checkout shortcode if you rely on the filters, though blocks are the supported direction.
Add a purely visual label with CSS, with the drawback that screen readers and search engines will not see it.
Open your cart page in the editor to see which type you use.
How do I test the change?
Add a simple product, a variable product and a sale product to the cart.
Look at the shop archive, a single product page, the cart and the checkout.
Check the prefix does not appear on products with no price.
Check structured data and Google Merchant feeds are unaffected, since the filter changes HTML only. Review any plugin that copies price HTML into feeds.
What can go wrong?
Caching layers can show the old price HTML until cleared. Plugins that change prices, such as wholesale or currency tools, may already filter the same hook, and priorities decide who wins. Currency switchers may place their symbol before your prefix, so test each currency, and keep prefixes short for mobile product grids.
Which suffix placeholders can I use?
| Placeholder | Shows |
|---|---|
{price_including_tax} | The price with tax |
{price_excluding_tax} | The price without tax |
Plain text such as inc. VAT | The text as written |
By customer role, country or stock status, built and tested.
Is there a way to add text after the price without code?
Yes. WooCommerce has a Price display suffix in Settings, Tax, which accepts text such as "inc. VAT" and can show tax-inclusive and tax-exclusive amounts.
Link to this answerWhy does my text not appear in the cart or checkout?
Stores on the Cart and Checkout blocks do not use the classic cart price filters. Those blocks need different hooks or settings, or the classic shortcode templates.
Link to this answerWhere should the code go?
In a small custom plugin or a child theme's functions.php. Do not edit the parent theme or WooCommerce files.
Link to this answerWhy is the Price display suffix setting missing?
It appears only when taxes are enabled in Settings, General. If you do not charge tax, use the filter instead.
Link to this answerWhich placeholders does the suffix setting accept?
{price_including_tax} and {price_excluding_tax}, so you can show something like 12.00 excluding tax after the price. It follows each product's tax status.
Link to this answerWhy is the empty-price check in the filter?
It prevents text such as From per licence appearing on products with no price, for example products with a blank price or ones that are out of stock with the price hidden. It returns the unchanged markup instead.
Link to this answerHow do I limit the text to one category?
Test the product inside the filter with has_term() on its category and return the unchanged price HTML otherwise. For variable products get_id() is the parent ID, which is right for category checks.
Link to this answerWhy does my cart callback fail?
The cart price filter passes the price, the cart item array and the cart item key, not the product. A callback written for the product-page filter will fail, so use a separate function per filter.
Link to this answerDoes this change the real price in feeds or structured data?
No, the filter changes HTML only. If a plugin copies the price HTML into feeds, your text may leak in, so review that.
Link to this answerHow do I translate the labels?
Wrap them in translation functions and translate with Loco Translate or your multilingual plugin. Keep prefixes short, since long phrases wrap awkwardly on mobile grids.
Link to this answerWhy does my text double up?
Plugins that change prices, such as wholesale or currency tools, may filter the same hook, and priorities decide who wins. Remove one source.
Link to this answerCan you build conditional labels for me?
Yes. Our WooCommerce experts can build and test labels by customer role, country or stock status across cart and checkout blocks, and smaller adjustments are part of customization services.
Link to this answerKeep reading
Want an engineer on it?
Tell us what is wrong in plain words. A person reads it, today.