Skip to content

Commit 42e19f1

Browse files
authored
Merge pull request woocommerce#16678 from Drivingralle/patch-3
Pass unformated price into filter to allow better overwrite
2 parents a37741b + 245c354 commit 42e19f1

File tree

1 file changed

+12
-4
lines changed

1 file changed

+12
-4
lines changed

includes/wc-formatting-functions.php

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -489,9 +489,10 @@ function wc_price( $price, $args = array() ) {
489489
'price_format' => get_woocommerce_price_format(),
490490
) ) ) );
491491

492-
$negative = $price < 0;
493-
$price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
494-
$price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator );
492+
$unformatted_price = $price;
493+
$negative = $price < 0;
494+
$price = apply_filters( 'raw_woocommerce_price', floatval( $negative ? $price * -1 : $price ) );
495+
$price = apply_filters( 'formatted_woocommerce_price', number_format( $price, $decimals, $decimal_separator, $thousand_separator ), $price, $decimals, $decimal_separator, $thousand_separator );
495496

496497
if ( apply_filters( 'woocommerce_price_trim_zeros', false ) && $decimals > 0 ) {
497498
$price = wc_trim_zeros( $price );
@@ -504,7 +505,14 @@ function wc_price( $price, $args = array() ) {
504505
$return .= ' <small class="woocommerce-Price-taxLabel tax_label">' . WC()->countries->ex_tax_or_vat() . '</small>';
505506
}
506507

507-
return apply_filters( 'wc_price', $return, $price, $args );
508+
/**
509+
* Filters the string of price markup.
510+
*
511+
* @param string $return Price HTML markup
512+
* @param float $unformatted_price Price as float to allow plugins custom formatting
513+
* @param array $args Pass on the args
514+
*/
515+
return apply_filters( 'wc_price', $return, $unformatted_price, $args );
508516
}
509517

510518
/**

0 commit comments

Comments
 (0)