Automattic\WooCommerce\Blocks
QueryFilters::price_filter_clauses()
Add query clauses for price filter.
Method of the class: QueryFilters{}
No Hooks.
Return
Array
.
Usage
// private - for code of main (parent) class only $result = $this->price_filter_clauses( $args, $wp_query );
- $args(array) (required)
- Query args.
- $wp_query(\WP_Query) (required)
- WP_Query object.
QueryFilters::price_filter_clauses() QueryFilters::price filter clauses code WC 9.4.2
private function price_filter_clauses( $args, $wp_query ) { if ( ! $wp_query->get( 'min_price' ) && ! $wp_query->get( 'max_price' ) ) { return $args; } global $wpdb; $adjust_for_taxes = $this->adjust_price_filters_for_displayed_taxes(); $args['join'] = $this->append_product_sorting_table_join( $args['join'] ); if ( $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, 'max_price', '>=' ); } else { $args['where'] .= $wpdb->prepare( ' AND wc_product_meta_lookup.max_price >= %f ', $min_price_filter ); } } if ( $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, 'min_price', '<=' ); } else { $args['where'] .= $wpdb->prepare( ' AND wc_product_meta_lookup.min_price <= %f ', $max_price_filter ); } } return $args; }