-
-
Save propertyhive/bc79d5416c936503f63a4c1190dc2f7a to your computer and use it in GitHub Desktop.
Property Hive - Real time feed - override To Rent price qualifier
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( 'ph_rtdf_send_request_data', 'set_price_qualifier_for_commercial_rent_rtdf', 10, 2 ); | |
| function set_price_qualifier_for_commercial_rent_rtdf( $request_data, $post_id ) | |
| { | |
| $property = new PH_Property( $post_id ); | |
| if ( ! $property ) | |
| { | |
| return $request_data; | |
| } | |
| $original_department = $property->department; | |
| // Check if department is commercial | |
| if ( | |
| $original_department === 'commercial' || | |
| ph_get_custom_department_based_on( $original_department ) === 'commercial' | |
| ) { | |
| // Check if property is to rent AND for sale | |
| if ( | |
| $property->to_rent === 'yes' && | |
| $property->for_sale === 'yes' | |
| ) { | |
| if ( | |
| isset($request_data['branch']['channel']) && | |
| $request_data['branch']['channel'] === 2 && | |
| isset( $request_data['property']['price_information']['price_qualifier'] ) | |
| ) { | |
| unset( $request_data['property']['price_information']['price_qualifier'] ); | |
| } | |
| if ( | |
| isset($request_data['branch']['channel']) && | |
| $request_data['branch']['channel'] === 1 | |
| ) { | |
| // Check if price qualifier is 'Non-Quoting' | |
| $terms = wp_get_post_terms( $post_id, 'price_qualifier' ); | |
| if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) { | |
| foreach ( $terms as $term ) { | |
| if ( strtolower( $term->name ) === 'non-quoting' ) { | |
| $request_data['property']['price_information']['price_qualifier'] = 1; // Set to POA | |
| break; | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| return $request_data; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment