Tribe__Tickets_Plus__Commerce__WooCommerce__Main::delayed_ticket_generation( int $order_id, string $unused_from = null, string $unused_to = null )

Adds a 5-second delay to ticket generation to help protect against race conditions.


Parameters

$order_id

(int) (Required) The id of the ticket order.

$unused_from

(string) (Optional) Deprecated. The status the order is transitioning from.

Default value: null

$unused_to

(string) (Optional) Deprecated. The status the order is transitioning to.

Default value: null


Top ↑

Source

File: src/Tribe/Commerce/WooCommerce/Main.php

	public function delayed_ticket_generation( $order_id, $unused_from = null, $unused_to = null ) {
		// If we're not using PayPal, we don't need to delay, just generate tickets
		if ( 'paypal' !== strtolower( get_post_meta( $order_id, '_payment_method', true ) ) ) {
			$this->generate_tickets( $order_id );
			return;
		}

		/**
		 * Allows users to customize the delay put in place
		 *
		 * @since 4.9.2
		 *
		 * @param string A date/time string. Note it must be positive!
		 */
		$ticket_delay = apply_filters( 'tribe_ticket_generation_delay', '+5 seconds', $order_id );
		$timestamp = strtotime( $ticket_delay );

		// In case the timestamp is borked, fall back to 5 seconds
		if ( ! $timestamp || $timestamp < time() ) {
			$timestamp = strtotime( '+5 seconds' );
		}

		if ( self::is_wc_paypal_gateway_active() && tribe_get_option( 'tickets-woo-paypal-delay', false ) ) {
			wp_schedule_single_event( $timestamp, 'tribe_wc_delayed_ticket_generation', array( $order_id ) );
		} else {
			$this->generate_tickets( $order_id );
		}
	}

Top ↑

Changelog

Changelog
Version Description
4.9.2 Introduced.