Filter by date doesn't working correctly

When I import an external calendar into HivePress, it adds the hidden bookings to the first list found for that provider. Then when I search for ads by available date, the first listing is hidden in the results, and the rest of the ads from that vendor are present in the search results. Here’s what I found in the plugin code (class-booking.php component):

public function set_search_clauses( $where, $query ) {
		global $wpdb;

		// Check query.
		if ( ! $query->is_search() || $query->get( 'post_type' ) !== 'hp_listing' ) {
			return $where;
		}

		if ( ! $query->is_main_query() && $query->get( 'meta_key' ) !== 'hp_featured' ) {
			return $where;
		}

		// Check request context.
		if ( ! hivepress()->request->get_context( 'booking_times' ) ) {
			return $where;
		}

		// Get time range.
		list($start_time, $end_time) = hivepress()->request->get_context( 'booking_times' );

		if ( ! $start_time || ! $end_time ) {
			return $where;
		}

		// Get subquery.
		$placeholder = implode( ', ', array_fill( 0, count( $this->get_blocked_statuses() ), '%s' ) );

		$subquery = $wpdb->prepare(
			"SELECT COUNT(*) FROM {$wpdb->posts} AS bookings
			INNER JOIN {$wpdb->postmeta} AS start_times ON ( bookings.ID = start_times.post_id )
			INNER JOIN {$wpdb->postmeta} AS end_times ON ( bookings.ID = end_times.post_id )
			WHERE bookings.post_status IN ( {$placeholder} ) AND bookings.post_type = %s
			AND bookings.post_parent = {$wpdb->posts}.ID
			AND start_times.meta_key = %s AND end_times.meta_key = %s
			AND (
				( CAST( start_times.meta_value AS SIGNED ) BETWEEN %d and %d )
				OR ( CAST( end_times.meta_value AS SIGNED ) BETWEEN %d and %d )
				OR (
					( CAST( start_times.meta_value AS SIGNED ) < %d )
					AND ( CAST( end_times.meta_value AS SIGNED ) > %d )
				)
			)",
			array_merge(
				$this->get_blocked_statuses(),
				[
					'hp_booking',
					'hp_start_time',
					'hp_end_time',
					$start_time,
					$end_time - 1,
					$start_time + 1,
					$end_time,
					$start_time,
					$end_time,
				]
			)
		);

		// Add clause.
		$where .= " AND ( {$subquery} ) = 0";

		return $where;
	}

What I mean:
For example, I have a vendor with ID 1000, he has 5 listings (1001, 1002, 1003, 1004, 1005). When importing an external calendar in which the date May 11, 2024 is occupied, a hidden booking with metadata is added to listing 1001 (the first one found):
hp_start_time: 1715385600
hp_end_time: 1715471999
And if you now search by the date of May 11, 2024, all listings of this vendor will be found in the search, except for 1001, which has a booking with the specified metadata. Logically, all 5 vendor listings should be excluded from the search. The “Manage availability per vendor” option is enabled.

Hi,

Thanks for reporting this, the bug is confirmed and we’ll fix it as soon as possible. Also, please note that even if you try to book an available listing, you will get an error (but only when per-vendor mode is enabled).

P.S. If you purchased a theme or extension, please enter the license key in the forum profile settings, this will enable the Premium Support badge and ensure a 24-hour turnaround time.

We have duplicated the question to your support email support@hivepress.io , where we have indicated the purchase key. We we would like to know the approximate time frame for solving the problem. Sorry for the urgency.

Hi, hivepress team. I am the website owner. We are getting complaints from customers about this. As a new business we can’t afford to get a bad public review at the stage we are at. Can you let me know when this will be fixed? thanks

Hi,

We will release an update within 10 days with a fix for this feature.

Hi, can you confirm if this is now released?

Hi,

Unfortunately, not yet, as the fix is more complicated. We will try to fix it as soon as possible.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.