Merge pull request #16678 from Drivingralle/patch-3

Pass unformated price into filter to allow better overwrite
This commit is contained in:
Mike Jolley 2017-09-04 10:15:51 +01:00 committed by GitHub
commit 42e19f1bb8
1 changed files with 12 additions and 4 deletions

View File

@ -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 .= ' <small class="woocommerce-Price-taxLabel tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
}
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 );
}
/**