Merge pull request #14752 from woocommerce/pr/14732
revert price handling of get_price_html()
This commit is contained in:
commit
a6329fa68c
|
@ -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 );
|
||||
} elseif ( $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();
|
||||
|
|
|
@ -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 );
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue