Created
October 20, 2025 10:45
-
-
Save propertyhive/7cc9e4f5052c1b162d1d6f48ed245bb9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| add_filter( 'propertyhive_property_query_meta_query', 'custom_commercial_price_query', 10, 2 ); | |
| function custom_commercial_price_query( $meta_query, $query ) | |
| { | |
| if ( ! is_array( $meta_query ) ) { | |
| $meta_query = array(); | |
| } | |
| if ( | |
| isset( $_REQUEST['department'] ) && ( $_REQUEST['department'] == 'commercial' || ph_get_custom_department_based_on($_REQUEST['department']) == 'commercial' ) && | |
| isset( $_REQUEST['commercial_minimum_price'] ) && $_REQUEST['commercial_minimum_price'] != '' | |
| ) | |
| { | |
| $minimum_price = $_REQUEST['commercial_minimum_price']; | |
| if ( is_numeric($minimum_price) ) | |
| { | |
| $meta_query[] = array( | |
| 'key' => '_price_to_actual', | |
| 'value' => ph_clean( floor( $minimum_price ) ), | |
| 'compare' => '>=', | |
| 'type' => 'NUMERIC' | |
| ); | |
| } | |
| } | |
| if ( | |
| isset( $_REQUEST['department'] ) && ( $_REQUEST['department'] == 'commercial' || ph_get_custom_department_based_on($_REQUEST['department']) == 'commercial' ) && | |
| isset( $_REQUEST['commercial_maximum_price'] ) && $_REQUEST['commercial_maximum_price'] != '' | |
| ) | |
| { | |
| $maximum_price = $_REQUEST['commercial_maximum_price']; | |
| if ( is_numeric($maximum_price) ) | |
| { | |
| $meta_query[] = array( | |
| 'key' => '_price_from_actual', | |
| 'value' => ph_clean( ceil( $maximum_price ) ), | |
| 'compare' => '<=', | |
| 'type' => 'NUMERIC' | |
| ); | |
| } | |
| } | |
| if ( | |
| isset( $_REQUEST['department'] ) && ( $_REQUEST['department'] == 'commercial' || ph_get_custom_department_based_on($_REQUEST['department']) == 'commercial' ) && | |
| isset( $_REQUEST['commercial_minimum_rent'] ) && $_REQUEST['commercial_minimum_rent'] != '' | |
| ) | |
| { | |
| $minimum_rent = $_REQUEST['commercial_minimum_rent']; | |
| if ( is_numeric($minimum_rent) ) | |
| { | |
| $meta_query[] = array( | |
| 'key' => '_rent_to_actual', | |
| 'value' => ph_clean( floor( $minimum_rent ) ), | |
| 'compare' => '>=', | |
| 'type' => 'NUMERIC' | |
| ); | |
| } | |
| } | |
| if ( | |
| isset( $_REQUEST['department'] ) && ( $_REQUEST['department'] == 'commercial' || ph_get_custom_department_based_on($_REQUEST['department']) == 'commercial' ) && | |
| isset( $_REQUEST['commercial_maximum_rent'] ) && $_REQUEST['commercial_maximum_rent'] != '' | |
| ) | |
| { | |
| $maximum_rent = $_REQUEST['commercial_maximum_rent']; | |
| if ( is_numeric($maximum_rent) ) | |
| { | |
| $meta_query[] = array( | |
| 'key' => '_rent_from_actual', | |
| 'value' => ph_clean( ceil( $maximum_rent ) ), | |
| 'compare' => '<=', | |
| 'type' => 'NUMERIC' | |
| ); | |
| } | |
| } | |
| return $meta_query; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment