Skip to content

Commit

Permalink
Merge pull request woocommerce#16678 from Drivingralle/patch-3
Browse files Browse the repository at this point in the history
Pass unformated price into filter to allow better overwrite
  • Loading branch information
mikejolley authored Sep 4, 2017
2 parents a37741b + 245c354 commit 42e19f1
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions includes/wc-formatting-functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand All @@ -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 );
}

/**
Expand Down

0 comments on commit 42e19f1

Please sign in to comment.