Tribe__Tickets__Tickets::get_event_ticket_provider_object( int $post_id = null )

Given a post ID, get the instance of the saved or default ticket provider class.

Will return False if there is a saved provider that is currently not active. Example: If provider is WooCommerce Ticket but ETP is inactive, will return False.

See also #


Top ↑

Parameters #

$post_id

(int) (Optional) The post ID of the event to which the ticket is attached.

Default value: null


Top ↑

Return #

(self|false) Instance of child class (if confirmed active) or False if provider is not active.


Top ↑

Source #

File: src/Tribe/Tickets.php

		public static function get_event_ticket_provider_object( $post_id = null ) {
			/** @var Tribe__Tickets__Tickets_Handler $tickets_handler */
			$tickets_handler = tribe( 'tickets.handler' );

			// 'Tribe__Tickets__RSVP' unless filtered.
			$provider = self::get_default_module();

			// If post ID is set and a value has been saved.
			if ( ! empty( $post_id ) ) {
				$saved = get_post_meta( $post_id, $tickets_handler->key_provider_field, true );

				if ( ! empty( $saved ) ) {
					$provider = $saved;
				}
			}

			return static::get_ticket_provider_instance( $provider );
		}

Top ↑

Changelog #

Changelog
Version Description
4.12.3 Introduced.