WooCommerce::print_series_pass_details( TECTickets_PlusFlexible_Ticketsarray $details, WP_Post $post, int $ticket_id )

Prints the series pass details in the WooCommerce order.


Parameters

$details

(<span class="TECTickets_PlusFlexible_Ticketsarray">TECTickets_PlusFlexible_Ticketsarray) (Required) The details to print.

$post

(WP_Post) (Required) The post object the Ticket is attached to.

$ticket_id

(int) (Required) The ID of the ticket.


Top ↑

Return

(TECTickets_PlusFlexible_Ticketsarray<string>) The details to print.


Top ↑

Source

File: src/Tickets_Plus/Flexible_Tickets/WooCommerce.php

	public function print_series_pass_details( array $details, $post, int $ticket_id ): array {
		if ( get_post_meta( $ticket_id, '_type', true ) !== Series_Passes::TICKET_TYPE ) {
			// Not a Series Pass.
			return $details;
		}

		if ( get_post_type( $post ) !== Series_Post_Type::POSTTYPE ) {
			// Not a Series post.
			return $details;
		}

		$details[] = sprintf(
			'<a href="%1$s" class="event-title">%2$s</a>',
			esc_attr( get_permalink( $post ) ),
			esc_html( get_the_title( $post ) )
		);

		$event_post_ids = Series_Relationship::where( 'series_post_id', '=', $post->ID )
		                                     ->pluck( 'event_post_id' );
		$first          = Occurrence::where_in( 'post_id', $event_post_ids )
		                            ->order_by( 'start_date', 'ASC' )->first();
		$last           = Occurrence::where_in( 'post_id', $event_post_ids )
		                            ->order_by( 'start_date', 'DESC' )->first();

		if ( ! ( $first instanceof Occurrence && $last instanceof Occurrence ) ) {
			// Do not print a date range if there are not first and last; fine to print about the same Event.
			return $details;
		}

		$format              = '<em><span class="tribe-event-date-start">%s</span>%s<span class="tribe-event-date-end">%s</span></em>';
		$first_start         = Dates::immutable( $first->start_date );
		$last_end            = Dates::immutable( $last->end_date );
		$start_end_same_year = $first_start->format( 'Y' ) === $last_end->format( 'Y' );
		$date_format         = $start_end_same_year ?
			tribe_get_option( 'dateWithoutYearFormat', 'F j' )
			: tribe_get_option( 'dateWithYearFormat', 'F j, Y' );
		$details[]           = sprintf(
			$format,
			esc_html( $first_start->format( $date_format ) ),
			tribe_get_option( 'timeRangeSeparator', ' - ' ),
			esc_html( $last_end->format( $date_format ) )
		);

		return $details;
	}

Top ↑

Changelog

Changelog
Version Description
5.9.0 Introduced.