Created
June 24, 2026 09:52
-
-
Save propertyhive/19f198cd9f15946b32ff1c27c9be59a0 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_action( "propertyhive_property_imported_rtdf", "correct_commercial_property_availability", 10, 3 ); | |
| function correct_commercial_property_availability( $post_id, $property, $import_id ) | |
| { | |
| $department = get_post_meta( $post_id, '_department', true ); | |
| if ( $department == 'commercial' ) | |
| { | |
| $to_rent = get_post_meta( $post_id, '_to_rent', true ); | |
| if ( $to_rent == 'yes' ) | |
| { | |
| if ( isset($property['status']) && $property['status'] == '1' ) | |
| { | |
| // It's a lettings-only commercial property sent with status '1 - available' | |
| wp_suspend_cache_invalidation( true ); | |
| wp_defer_term_counting( true ); | |
| wp_defer_comment_counting( true ); | |
| wp_set_object_terms( $post_id, 14, 'availability' ); // 14 = 'TO LET' TERM ID IN PROPERTY HIVE | |
| wp_suspend_cache_invalidation( false ); | |
| wp_defer_term_counting( false ); | |
| wp_defer_comment_counting( false ); | |
| } | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment