wc_format_sale_price()WC 3.0.0

Format a sale price for display.

Hooks from the function

Return

String.

Usage

wc_format_sale_price( $regular_price, $sale_price );
$regular_price(string) (required)
Regular price.
$sale_price(string) (required)
Sale price.

Changelog

Since 3.0.0 Introduced.

wc_format_sale_price() code WC 8.7.0

function wc_format_sale_price( $regular_price, $sale_price ) {
	$price = '<del aria-hidden="true">' . ( is_numeric( $regular_price ) ? wc_price( $regular_price ) : $regular_price ) . '</del> <ins>' . ( is_numeric( $sale_price ) ? wc_price( $sale_price ) : $sale_price ) . '</ins>';
	return apply_filters( 'woocommerce_format_sale_price', $price, $regular_price, $sale_price );
}