WordPress filter hook

woocommerce_format_sale_price

Defined by WooCommerce and fired by 6 plugins in total, running on 7M+ sites between them.

“To shopw format of sale price”

How to use woocommerce_format_sale_price

It's a filter: your callback receives the value and 2 more arguments, and must return the (changed) value. Add this to your theme's functions.php or a small custom plugin:

functions.php
add_filter( 'woocommerce_format_sale_price', function( $price, $regular_price, $sale_price ) {
	// Change $price here.
	return $price;
}, 10, 3 );

Argument names come from WooCommerce's source. Other plugins may pass different values: check the call in the plugin you're targeting below.

6 plugins that fire woocommerce_format_sale_price

Sorted by active installs. Each entry shows where the plugin calls the hook and what it passes.

  1. WooCommerce icon WooCommerce7+ million installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) includes/wc-formatting-functions.php:1397
  2. ELEX WooCommerce Role Based Pricing icon ELEX WooCommerce Role Based Pricing2,000+ installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) elex-includes/elex-functions.php:171
  3. ELEX WooCommerce Dynamic Pricing and Discounts icon ELEX WooCommerce Dynamic Pricing and Discounts700+ installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) includes/elex-common-functions.php:318
  4. FooSales icon FooSales700+ installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) admin/helpers/foosales-api-helper.php:164
  5. SOFT79 Pricing Rules for WooCommerce icon SOFT79 Pricing Rules for WooCommerce60+ installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) includes/soft79-rule-helpers.php:185
  6. Wow Extensions for WooCommerce icon Wow Extensions for WooCommerceFewer than 10 installs apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price ) extensions/role-based-pricing/wow-includes/wow-functions.php:171

Need a customisation built on this hook?

Tell us what you want to change and which plugin it's for. We'll write it, test it and send it back as a small plugin.