Skip to content

Instantly share code, notes, and snippets.

@NaokiStark
Created October 11, 2019 18:50
Show Gist options
  • Save NaokiStark/2adb2b36bf7c06eea5819b2406b65b76 to your computer and use it in GitHub Desktop.
Save NaokiStark/2adb2b36bf7c06eea5819b2406b65b76 to your computer and use it in GitHub Desktop.
public function get_price_html( $price = '' ) {
//$prices = $this->get_variation_prices( true );
$prices = ["price" => strval($this->price), "regular_price" => strval($this->price)];
if ( empty( $prices['price'] ) ) {
$price = apply_filters( 'woocommerce_variable_empty_price_html', '', $this );
} else {
$min_price = current( $prices['price'] );
$max_price = end( $prices['price'] );
$min_reg_price = current( $prices['regular_price'] );
$max_reg_price = end( $prices['regular_price'] );
$min_price = $min_reg_price = $max_price = $max_reg_price = strval($this->price);
if ( $min_price !== $max_price ) {
$price = wc_format_price_range( $min_price, $max_price );
} elseif ( $this->is_on_sale() && $min_reg_price === $max_reg_price ) {
$price = wc_format_sale_price( wc_price( $max_reg_price ), wc_price( $min_price ) );
} else {
$price = wc_price( $min_price );
}
$price = apply_filters( 'woocommerce_variable_price_html', $price . $this->get_price_suffix(), $this );
}
return apply_filters( 'woocommerce_get_price_html', $price, $this );
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment