This website uses cookies to personalize your experience. By using this website you agree to our cookie policy.

Reply To: pictures are not shown, drop down background

Home Forums Product Support Forums Ajax Search Pro for WordPress Support pictures are not shown, drop down background Reply To: pictures are not shown, drop down background

#24230
Ernest MarcinkoErnest Marcinko
Keymaster

Hi,

Thank you, that looks perfectly what I am looking for. Based on that, I looked at the source, and added an extra piece of code to the functions.php file in your theme directory to request the information from the calendar. Optimally it should exclude the items now, that the given function returns as not available. For future reference, I have added the following code:

// AJAX SEARCH PRO SPECIFIC
add_filter('asp_results', 'asp_filter_non_available_accomodations', 10, 4);
function asp_filter_non_available_accomodations($results, $search_id, $is_ajax, $args) {
	if ( !empty($args['post_meta_filter']) ) {
		foreach ( $args['post_meta_filter'] as $filter ) {
			$operator = $filter['operator'];
			$value = $filter['value'];
			$field = $filter['key'];
			if ( $field == 'mphb_start_date' ) {
				$from = $value . ' 00:00:00';
			} else if ( $field == 'mphb_end_date' ) {
				$to = $value . ' 00:00:00';;
			}
		}
		if ( isset($from, $to) ) {
			$dba = new HbDataBaseActions();
			foreach ( $results as $k => $r ) {
				if ( !$dba->is_available_accom($r->id, $from, $to) ) {
					unset($results[$k]);
				}
			}
		}
	}
	return $results;
}