tec_tribe_commerce_has_active_tickets()

Check if the site has created tickets using TribeCommerce.


Return

(bool)


Top ↑

Source

File: src/functions/commerce/provider.php

function tec_tribe_commerce_has_active_tickets() {
	if ( defined( 'TEC_TRIBE_COMMERCE_HAS_ACTIVE_TICKETS' ) ) {
		return (bool) TEC_TRIBE_COMMERCE_HAS_ACTIVE_TICKETS;
	}

	$env_var = getenv( 'TEC_TRIBE_COMMERCE_HAS_ACTIVE_TICKETS' );

	if ( false !== $env_var ) {
		return (bool) $env_var;
	}

	$cache_key = 'tec_tribe_commerce_has_active_tickets';
	$cached    = (bool) get_transient( $cache_key );

	if ( $cached ) {
		/**
		 * Filter whether we should disable TribeCommerce PayPal or not.
		 *
		 * @since 5.2.0
		 *
		 * @param boolean $available should be available or not.
		 */
		return apply_filters( 'tec_tribe_commerce_has_active_tickets', $cached );
	}

	$has_active_tickets = (bool) tribe_tickets()->by( 'post_type', 'tribe_tpp_tickets' )->where( 'is_active' )->count();

	// Cache the data.
	set_transient( $cache_key, $has_active_tickets, 24 * HOUR_IN_SECONDS );

	/**
	 * Filter whether we should disable TribeCommerce PayPal or not.
	 *
	 * @since 5.2.0
	 *
	 * @param boolean $available should be available or not.
	 */
	return apply_filters( 'tec_tribe_commerce_has_active_tickets', $has_active_tickets );

}

Top ↑

Changelog

Changelog
Version Description
5.2.0 Introduced.