Tribe__Tickets__Commerce__PayPal__Main::get_attendee( $attendee,  $post_id )

{@inheritdoc}


Source

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

	public function get_attendee( $attendee, $post_id = 0 ) {
		if ( is_numeric( $attendee ) ) {
			$attendee = get_post( $attendee );
		}

		if ( ! $attendee instanceof WP_Post || self::ATTENDEE_OBJECT !== $attendee->post_type ) {
			return false;
		}

		$checkin      = get_post_meta( $attendee->ID, $this->checkin_key, true );
		$security     = get_post_meta( $attendee->ID, $this->security_code, true );
		$order_id     = get_post_meta( $attendee->ID, $this->order_key, true );
		$product_id   = get_post_meta( $attendee->ID, $this->attendee_product_key, true );
		$optout       = (bool) get_post_meta( $attendee->ID, $this->attendee_optout_key, true );
		$status       = get_post_meta( $attendee->ID, $this->attendee_tpp_key, true );
		$user_id      = get_post_meta( $attendee->ID, $this->attendee_user_id, true );
		$ticket_sent  = (bool) get_post_meta( $attendee->ID, $this->attendee_ticket_sent, true );

		if ( empty( $product_id ) ) {
			return false;
		}

		$product       = get_post( $product_id );
		$product_title = ( ! empty( $product ) ) ? $product->post_title : get_post_meta( $attendee->ID, $this->deleted_product, true ) . ' ' . __( '(deleted)', 'event-tickets' );

		$ticket_unique_id = get_post_meta( $attendee->ID, '_unique_id', true );
		$ticket_unique_id = $ticket_unique_id === '' ? $attendee->ID : $ticket_unique_id;

		$meta = '';
		if ( class_exists( 'Tribe__Tickets_Plus__Meta', false ) ) {
			$meta = get_post_meta( $attendee->ID, Tribe__Tickets_Plus__Meta::META_KEY, true );

			// Process Meta to include value, slug, and label
			if ( ! empty( $meta ) ) {
				$meta = $this->process_attendee_meta( $product_id, $meta );
			}
		}

		$attendee_data = array_merge( $this->get_order_data( $attendee->ID ), array(
			'optout'       => $optout,
			'ticket'       => $product_title,
			'attendee_id'  => $attendee->ID,
			'security'     => $security,
			'product_id'   => $product_id,
			'check_in'     => $checkin,
			'order_status' => $status,
			'user_id'      => $user_id,
			'ticket_sent'  => $ticket_sent,

			// this is used to find existing attendees
			'post_title'   => $attendee->post_title,

			// Fields for Email Tickets
			'event_id'      => get_post_meta( $attendee->ID, $this->attendee_event_key, true ),
			'ticket_name'   => ! empty( $product ) ? $product->post_title : false,
			'holder_name'   => get_post_meta( $attendee->ID, $this->full_name, true ),
			'holder_email'  => get_post_meta( $attendee->ID, $this->email, true ),
			'order_id'      => $attendee->ID,
			'order_hash'    => $order_id,
			'ticket_id'     => $ticket_unique_id,
			'qr_ticket_id'  => $attendee->ID,
			'security_code' => $security,

			// Attendee Meta
			'attendee_meta' => $meta,
		) );

		/**
		 * Allow users to filter the Attendee Data
		 *
		 * @since 4.7
		 *
		 * @param array   $attendee_data An associative array with the Information of the Attendee
		 * @param string  $provider      What Provider is been used
		 * @param WP_Post $attendee      Attendee Object
		 *
		 */
		$attendee_data = apply_filters( 'tribe_tickets_attendee_data', $attendee_data, 'tpp', $attendee );

		return $attendee_data;
	}