wc_price WooCommerce Function: Examples and Formats [Guide]

wc_price function guide thumbnail with a price tag icon

Hard-coding a price like $49.90 in a template breaks the moment you change currency, decimal places, or move to a European layout.

That’s what wc_price() is for. It takes a number and returns a ready-to-print price with the right symbol, separators, and decimals. This guide covers the function’s arguments and walks through real use cases: showing prices with and without the currency, outputting plain text, switching separators for European markets, and changing the defaults site-wide with a filter.

What wc_price() Does

The function lives in WooCommerce’s formatting functions and has this signature:

<?php

wc_price( $price, $args = array() );

It returns an HTML string, not a number, so you can echo it directly. Only $price is required. Any argument you leave out falls back to the store’s Currency options under WooCommerce → Settings → General.

These are the arguments you will use most:

ArgumentDefaultWhat it controls
currencyStore currencyCurrency code for the symbol, such as EUR
decimalsStore settingDigits after the decimal separator
decimal_separatorStore settingCharacter between the whole and fractional parts
thousand_separatorStore settingCharacter between digit groups
price_formatStore settingPosition of symbol and amount, using %1$s for the symbol and %2$s for the amount
ex_tax_labelfalseAppends a tax suffix such as “excl. tax”
WooCommerce Currency options screen with currency, position, thousand separator, decimal separator, and number of decimals fields
WooCommerce → Settings → General → Currency options

Basic Usage: Price With Currency

Pass a number and echo the result. With the default settings, the output includes the store’s currency symbol:

<?php

echo wc_price( 49.9 );

On a US store, this prints $49.90. The markup looks roughly like this:

<span class="woocommerce-Price-amount amount"><bdi><span class="woocommerce-Price-currencySymbol">$</span>49.90</bdi></span>

Keep the span when you want WooCommerce’s price styling to apply, because the theme and the WooCommerce CSS target these classes.

Price Without the Currency Symbol

Sometimes the symbol already appears in the layout, such as a table header that reads “Price (USD)”. Set price_format to %2$s, which tells the function to print only the amount:

<?php

echo wc_price( 49.9, array( 'price_format' => '%2$s' ) );

This prints only the amount, 49.90, inside the same markup.

Plain Text Output for Feeds and Schema

The span markup breaks in places that expect plain text, such as email subjects, meta descriptions, CSV exports, and admin notices. Strip the tags with wp_strip_all_tags():

<?php

$price_text = wp_strip_all_tags( wc_price( 49.9 ) );

echo esc_attr( $price_text ); // $49.90

Structured data needs a different approach. Schema.org expects a plain number for the price, with the currency set separately, so pass the raw value from get_price() into your markup instead of the formatted string. Formatted text is for people, and raw numbers are for machines.

Custom Separators for Different Regions

Store-wide separators apply to every price. When a market uses a different convention, pass your own values. The decimal and thousand separators must be different characters, or the number becomes hard to read.

Comma Decimal Separator

Many European countries write 1.249,00 instead of 1,249.00. Set both separators, along with the symbol position:

<?php

echo wc_price( 1249, array(
    'currency'           => 'EUR',
    'decimal_separator'  => ',',
    'thousand_separator' => '.',
    'price_format'       => '%2$s %1$s',
) );

The %2$s %1$s format places the symbol after the amount with a space, which matches the common European layout.

Space as Thousands Separator

Several Nordic and Eastern European markets group digits with a space. A regular space can wrap onto a new line, so use a non-breaking space (U+00A0) to keep the number together:

<?php

echo wc_price( 1249.5, array(
    'currency'           => 'PLN',
    'decimal_separator'  => ',',
    'thousand_separator' => "\u{00A0}",
    'price_format'       => '%2$s %1$s',
) );

Changing Currency and Decimal Places

Currencies without minor units, such as the Japanese yen, should show no decimals. Set decimals to 0:

<?php

echo wc_price( 1250, array(
    'currency' => 'JPY',
    'decimals' => 0,
) );

This prints ¥1,250. The currency argument only changes how the number is formatted. WooCommerce does not convert values, so convert the amount yourself before you pass it in, for example when you show a comparison price based on an exchange rate. To change the store’s base currency instead of a single display, see how to change currency in WooCommerce.

Showing a Tax Label

Set ex_tax_label to true to append a short tax suffix such as “excl. tax”. The wording follows your store’s tax settings:

<?php

echo wc_price( 49.9, array( 'ex_tax_label' => true ) );

Use this where prices are shown without tax. Make sure the number you pass in is the net amount before you format it.

Sale Prices With Strikethrough

A product card often shows the regular price struck through next to the sale price. Combine two calls and wrap them in semantic tags:

<?php

$regular = 99;
$sale    = 79;

printf(
    '<del>%s</del> <ins>%s</ins>',
    wc_price( $regular ),
    wc_price( $sale )
);

The del element gets the strikethrough style, and the ins element marks the new price. Your theme’s CSS decides how both look.

Changing Defaults Site-Wide

When every price on the site needs the same change, filter the arguments instead of editing each call. The wc_price_args filter receives the arguments before the price is formatted. This example drops decimals for a store that sells whole units only:

<?php

add_filter( 'wc_price_args', 'my_whole_number_prices' );

function my_whole_number_prices( $args ) {
    $args['decimals'] = 0;

    return $args;
}

To change the currency symbol itself rather than the format, use the woocommerce_currency_symbol filter instead.

Common Mistakes

  • Escaping the output. wc_price() already returns markup. Wrapping it in esc_html() prints the tags as text.
  • Matching the separators. Using the same character for thousands and decimals makes the number ambiguous.
  • Converting currency inside the function. wc_price() only formats the number. It does not convert it.
  • Formatting values you still need to calculate with. Keep the raw number for math and format it only at output.

Tip: Check custom formats on the cart, checkout, and order emails too. Your theme may restyle the price spans, and a different separator can look out of place next to the rest of the layout.

FAQs About wc_price()

Is wc_price() Safe to Echo Directly?

Yes. The amount is a formatted number, and the output is meant for display. Don’t wrap it in esc_html(), because that prints the markup as text.

Does wc_price() Add Tax?

No. It formats the number you pass in. Calculate the tax first, then format the result. Use ex_tax_label only to add the suffix.

Can I Change the Currency Symbol?

Yes. Filter woocommerce_currency_symbol to replace the symbol for a currency code, for example to use your own abbreviation.

Does It Work With Variable Products?

Yes. Pass the price of the variation you are displaying. wc_price() does not read the product itself, so you decide which price to format.

Conclusion

wc_price() handles most price display in WooCommerce with a few arguments. Start with the defaults, change the format only where your layout needs it, and strip the tags for any output that is not HTML.

Need custom price displays, multi-currency support, or checkout changes? Hire a WooCommerce developer or reach out to me directly.

About The Author

Picture of Andriy Haydash

Andriy Haydash

Andriy Haydash is a WordPress Expert who helps people build and launch successful WordPress membership and e-learning websites.

Note: Not all of the articles are written directly by me.
Affiliate Disclaimer: Some links in the post may be my affiliate links

Kinsta - Managed Hosting for WordPress

Before YOU Leave...
Join My Newsletter

Get practical tips & tricks on how to start, grow and market your course/membership site.