[Experimental] Fix: get the correct min/max price for filtering (#43313)
This commit is contained in:
parent
009ff8707b
commit
37c94c7604
|
@ -0,0 +1,5 @@
|
|||
Significance: patch
|
||||
Type: fix
|
||||
Comment: Filter Blocks: fix the filtering price to make it work with any number of decimal setting.
|
||||
|
||||
|
|
@ -232,7 +232,7 @@ final class QueryFilters {
|
|||
$args['join'] = $this->append_product_sorting_table_join( $args['join'] );
|
||||
|
||||
if ( $wp_query->get( 'min_price' ) ) {
|
||||
$min_price_filter = $this->prepare_price_filter( $wp_query->get( 'min_price' ) );
|
||||
$min_price_filter = intval( $wp_query->get( 'min_price' ) );
|
||||
|
||||
if ( $adjust_for_taxes ) {
|
||||
$args['where'] .= $this->get_price_filter_query_for_displayed_taxes( $min_price_filter, 'min_price', '>=' );
|
||||
|
@ -242,7 +242,7 @@ final class QueryFilters {
|
|||
}
|
||||
|
||||
if ( $wp_query->get( 'max_price' ) ) {
|
||||
$max_price_filter = $this->prepare_price_filter( $wp_query->get( 'max_price' ) );
|
||||
$max_price_filter = intval( $wp_query->get( 'max_price' ) );
|
||||
|
||||
if ( $adjust_for_taxes ) {
|
||||
$args['where'] .= $this->get_price_filter_query_for_displayed_taxes( $max_price_filter, 'max_price', '<=' );
|
||||
|
@ -350,16 +350,6 @@ final class QueryFilters {
|
|||
return $display !== $database;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts price filter from subunits to decimal.
|
||||
*
|
||||
* @param string|int $price_filter Raw price filter in subunit format.
|
||||
* @return float Price filter in decimal format.
|
||||
*/
|
||||
private function prepare_price_filter( $price_filter ) {
|
||||
return floatval( $price_filter / ( 10 ** wc_get_price_decimals() ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts a price filter based on a tax class and whether or not the amount includes or excludes taxes.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue