wc_format_price_range()
Format a price range for display.
Hooks from the function
Returns
String.
Usage
wc_format_price_range( $from, $to );
- $from(string) (required)
- Price from.
- $to(string) (required)
- Price to.
wc_format_price_range() wc format price range code WC 10.5.0
function wc_format_price_range( $from, $to ) {
/* translators: 1: price from 2: price to */
$price = sprintf( _x( '%1$s <span aria-hidden="true">–</span> %2$s', 'Price range: from-to', 'woocommerce' ), is_numeric( $from ) ? wc_price( $from, array( 'aria-hidden' => true ) ) : $from, is_numeric( $to ) ? wc_price( $to, array( 'aria-hidden' => true ) ) : $to );
$price .= '<span class="screen-reader-text">';
$price .= sprintf(
/* translators: 1: price from 2: price to */
__( 'Price range: %1$s through %2$s', 'woocommerce' ),
is_numeric( $from ) ? wp_strip_all_tags( wc_price( $from ) ) : wp_strip_all_tags( $from ),
is_numeric( $to ) ? wp_strip_all_tags( wc_price( $to ) ) : wp_strip_all_tags( $to )
);
$price .= '</span>';
return apply_filters( 'woocommerce_format_price_range', $price, $from, $to );
}