revert price handling so null price still is filtered by woocommerce_get_price_html. closes #14727.

This commit is contained in:
Kathy Darling 2017-04-26 12:37:30 -05:00
parent 16345137e2
commit 36dbe64170
2 changed files with 16 additions and 17 deletions

View File

@ -1643,10 +1643,8 @@ class WC_Product extends WC_Abstract_Legacy_Product {
*/
public function get_price_html( $deprecated = '' ) {
if ( '' === $this->get_price() ) {
return apply_filters( 'woocommerce_empty_price_html', '', $this );
}
if ( $this->is_on_sale() ) {
$price = apply_filters( 'woocommerce_empty_price_html', '', $this );
} else if ( $this->is_on_sale() ) {
$price = wc_format_sale_price( wc_get_price_to_display( $this, array( 'price' => $this->get_regular_price() ) ), wc_get_price_to_display( $this ) ) . $this->get_price_suffix();
} else {
$price = wc_price( wc_get_price_to_display( $this ) ) . $this->get_price_suffix();

View File

@ -135,21 +135,22 @@ class WC_Product_Variable extends WC_Product {
$prices = $this->get_variation_prices( true );
if ( empty( $prices['price'] ) ) {
return apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
}
$min_price = current( $prices['price'] );
$max_price = end( $prices['price'] );
$min_reg_price = current( $prices['regular_price'] );
$max_reg_price = end( $prices['regular_price'] );
if ( $min_price !== $max_price ) {
$price = apply_filters( 'woocommerce_variable_price_html', wc_format_price_range( $min_price, $max_price ) . $this->get_price_suffix(), $this );
} elseif ( $this->is_on_sale() && $min_reg_price === $max_reg_price ) {
$price = apply_filters( 'woocommerce_variable_price_html', wc_format_sale_price( wc_price( $max_reg_price ), wc_price( $min_price ) ) . $this->get_price_suffix(), $this );
$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
} else {
$price = apply_filters( 'woocommerce_variable_price_html', wc_price( $min_price ) . $this->get_price_suffix(), $this );
$min_price = current( $prices['price'] );
$max_price = end( $prices['price'] );
$min_reg_price = current( $prices['regular_price'] );
$max_reg_price = end( $prices['regular_price'] );
if ( $min_price !== $max_price ) {
$price = apply_filters( 'woocommerce_variable_price_html', wc_format_price_range( $min_price, $max_price ) . $this->get_price_suffix(), $this );
} elseif ( $this->is_on_sale() && $min_reg_price === $max_reg_price ) {
$price = apply_filters( 'woocommerce_variable_price_html', wc_format_sale_price( wc_price( $max_reg_price ), wc_price( $min_price ) ) . $this->get_price_suffix(), $this );
} else {
$price = apply_filters( 'woocommerce_variable_price_html', wc_price( $min_price ) . $this->get_price_suffix(), $this );
}
}
return apply_filters( 'woocommerce_get_price_html', $price, $this );
}