From 245c35420968dc0fe2451b142bf7a3c63656ddff Mon Sep 17 00:00:00 2001 From: Ralf Wiechers Date: Fri, 1 Sep 2017 17:50:06 +0200 Subject: [PATCH] Pass unformated price into filter to allow better overwrite Attempt to fix #16674. Tried to add som PhpDocs to make --- includes/wc-formatting-functions.php | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/includes/wc-formatting-functions.php b/includes/wc-formatting-functions.php index ed6931ffb82..d4499c8c8d6 100644 --- a/includes/wc-formatting-functions.php +++ b/includes/wc-formatting-functions.php @@ -489,9 +489,10 @@ function wc_price( $price, $args = array() ) { 'price_format' => get_woocommerce_price_format(), ) ) ) ); - $negative = $price < 0; - $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) ); - $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator ); + $unformatted_price = $price; + $negative = $price < 0; + $price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) ); + $price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator ); if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $decimals > 0 ) { $price = wc_trim_zeros( $price ); @@ -504,7 +505,14 @@ function wc_price( $price, $args = array() ) { $return .= ' ' . WC()->countries->ex_tax_or_vat() . ''; } - return apply_filters( 'wc_price', $return, $price, $args ); + /** + * Filters the string of price markup. + * + * @param string $return Price HTML markup + * @param float $unformatted_price Price as float to allow plugins custom formatting + * @param array $args Pass on the args + */ + return apply_filters( 'wc_price', $return, $unformatted_price, $args ); } /**