Skip to content

Commit

Permalink
Improve address display for undisclosed address
Browse files Browse the repository at this point in the history
When `internetAddressDisplay` is set to false, some feeds do not
contain the city, state, or zip code as well. This prevents extra
commas from being displayed when this address information is null.
  • Loading branch information
CodyReichert committed Feb 23, 2024
1 parent 97fca9e commit f0b5527
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/simply-rets-utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,13 @@ public static function buildFullAddressString($listing) {
$state = $listing->address->state;
$zip = $listing->address->postalCode;

// A listing might have a null address if a flag like "Display
// address" is set to false. This just removes the comma in
// these cases, but the rest of the address remains the same.
$comma = $address ? ', ' : '';
// When `internetAddressDisplay` is false, some feeds may also
// exclude city, state, and zip. This ensures that commas are
// only used when these fields exist.
$comma1 = ($address AND ($city OR $state OR $zip)) ? ', ' : '';
$comma2 = $city ? ', ' : '';

return $address . $comma . $city . ', ' . $state . ' ' . $zip;
return $address . $comma1 . $city . $comma2 . $state . ' ' . $zip;
}

/**
Expand Down

0 comments on commit f0b5527

Please sign in to comment.