Last active
November 11, 2025 12:53
-
-
Save propertyhive/233cb238831922a586d0fda59d79eeea 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_price_output', 'student_per_person', 10, 5 ); | |
| function student_per_person($return, $property, $currency, $prefix, $suffix) | |
| { | |
| if ( $property->department != 'student' ) | |
| { | |
| return $return; | |
| } | |
| $bedrooms = (int)$property->bedrooms; | |
| if ( empty($bedrooms) ) | |
| { | |
| return $return; | |
| } | |
| // monthly per person | |
| $monthly_rent = $property->price_actual; | |
| $monthly_rent_per_person = $monthly_rent / $bedrooms; | |
| $monthly_rent_per_person = ceil($monthly_rent_per_person * 100) / 100; | |
| $monthly_rent_per_person = number_format($monthly_rent_per_person, 2, '.', ''); | |
| // weekly per person | |
| $weekly_rent = ($property->price_actual * 12) / 52; | |
| $weekly_rent_per_person = $weekly_rent / $bedrooms; | |
| $weekly_rent_per_person = ceil($weekly_rent_per_person * 100) / 100; | |
| $weekly_rent_per_person = number_format($weekly_rent_per_person, 2, '.', ''); | |
| $return = '£' . $monthly_rent_per_person . ' per month per person (£' . $weekly_rent_per_person . ' per week per person)'; | |
| return $return; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment