Tribe__Tickets__Tickets::maybe_redirect_to_attendees_registration_screen( string|null $redirect = null, null|int $post_id = null )

If tickets exist in the cart for which we don’t have meta info, redirect to the meta collection screen.


Parameters

$redirect

(string|null) (Optional) URL to redirect to.

Default value: null

$post_id

(null|int) (Optional) Post ID for cart.

Default value: null


Top ↑

Source

File: src/Tribe/Tickets.php

		public function maybe_redirect_to_attendees_registration_screen( $redirect = null ) {

			// Bail if the meta storage class doesn't exist
			if ( ! class_exists( 'Tribe__Tickets_Plus__Meta__Storage' ) ) {
				return;
			}

			if ( ! class_exists( 'Tribe__Tickets_Plus__Main' ) ) {
				return;
			}

			// They're submitting RSVPs, do not include them for now
			if ( ! empty( $_POST['tribe_tickets_rsvp_submission'] ) ) {
				return;
			}

			if ( tribe( 'tickets.attendee_registration' )->is_on_page() ) {
				return;
			}

			// Return if not trying to access the checkout page
			if ( ! $this->is_checkout_page() ) {
				return;
			}

			/**
	 		 * Modify the tickets in cart, useful to
	 		 * change the contents for each vendor
			 * @since 4.9
			 *
			 * @param array
			*/
			$tickets_in_cart = apply_filters( 'tribe_tickets_tickets_in_cart', [] );

			// Bail if there are no tickets
			if ( empty( $tickets_in_cart ) ) {
				return;
			}

			$is_paypal = (bool) $redirect;

			/** @var Tribe__Tickets_Plus__Meta $meta */
			$meta = tribe( 'tickets-plus.main' )->meta();

			$cart_has_meta = true;

			// If the method exists (latest ET+ version), run it.
			if ( method_exists( $meta, 'cart_has_meta' ) ) {
				$cart_has_meta = $meta->cart_has_meta( $tickets_in_cart );
			}

			$cart_has_required_meta = $meta->cart_has_required_meta( $tickets_in_cart );
			$up_to_date             = tribe( 'tickets-plus.meta.contents' )->is_stored_meta_up_to_date( $tickets_in_cart );

			// If WooCommerce or EDD
			if ( ! $is_paypal ) {
				// Bail if there are no required fields in cart or the stored data is up to date
				// And they're submitting the Attendee Registration page
				if (
					isset( $_REQUEST['tribe_tickets_checkout'] )
						&& ( ! $cart_has_required_meta || $up_to_date )
				) {
					return;
				}

				// Bail If things are up to date and they haven't submitted the form
				// to access the registration page.
				if (
					$up_to_date
						&& ! isset( $_REQUEST['wootickets_process'] )
						&& ! isset( $_REQUEST['eddtickets_process'] )
				) {
					return;
				}

				// Bail if processing checkout for WooCommerce
				if ( isset( $_REQUEST['key'] ) ) {
					return;
				}
			}
			// If PayPal and cart does not have meta
			elseif ( ! $cart_has_meta ) {
				return;
			}

			$url = tribe( 'tickets.attendee_registration' )->get_url();

			$storage = new Tribe__Tickets_Plus__Meta__Storage();
			if ( ! empty( $redirect ) ) {
				$key = $storage->store_temporary_data( $redirect );
				/** @var \Tribe__Tickets__Commerce__PayPal__Main $commerce_paypal */
				$commerce_paypal = tribe( 'tickets.commerce.paypal' );

				$url = add_query_arg( array( 'event_tickets_redirect_to' => $key, 'provider' => $commerce_paypal->attendee_object ), $url );
			}

			wp_safe_redirect( $url, 307 );
			exit;
		}

Top ↑

Changelog

Changelog
Version Description
5.0.2 Correct provider attendee object.
4.9 Introduced.