public static function getOtherPeopleAlsoViewedHTML($post, $options = array()) { $session_id = Registry::get('session_id'); // No session id found - terminate the function. if ($session_id === null) { return false; } $other_people_also_viewed = get_option(USE_PREFIX . 'other_people_also_viewed'); if (false !== $other_people_also_viewed) { $other_people_also_viewed = unserialize($other_people_also_viewed); } else { $other_people_also_viewed = array(); } $seen_properties = array(); // Loop through all sessions foreach ($other_people_also_viewed as $_session_id => $_properties) { // Loop though each session's properties seen foreach ($_properties as $_property_id) { // If any of the properties match the current property if ($_property_id == $post->ID) { $seen_properties = array_merge($seen_properties, $_properties); } } } // Remove any dublications $seen_properties = array_unique($seen_properties); // Remove current property list $seen_properties = array_diff($seen_properties, array($post->ID)); // Create a session ID for this customer if (!isset($other_people_also_viewed[$session_id])) { $other_people_also_viewed[$session_id] = array(); } $other_people_also_viewed[$session_id][] = $post->ID; $other_people_also_viewed[$session_id] = array_unique($other_people_also_viewed[$session_id]); $other_people_also_viewed = serialize($other_people_also_viewed); $result = update_option(USE_PREFIX . 'other_people_also_viewed', $other_people_also_viewed); $options = array('post__in' => $seen_properties, 'post_type' => 'properties', 'post_status' => 'publish', 'properties_per_page' => 10000); $properties = PropertiesManager::searchProperties($options); ob_start(); $list_style = 'carousel'; require COMPONENTS_PATH . DIRECTORY_SEPARATOR . "common" . DIRECTORY_SEPARATOR . "properties.php"; $content .= ob_get_contents(); ob_end_clean(); return $content; }