Tribe__Tickets__Commerce__PayPal__Main::update_attendee_data( array $attendee_data, int $attendee_id, int $post_id )

Update the PayPalTicket values for this user.

Note that, within this method, $order_id refers to the attendee or ticket ID (it does not refer to an "order" in the sense of a transaction that may include multiple tickets, as is the case in some other methods for instance).


Parameters

$attendee_data

(array) (Required) Information that we are trying to save.

$attendee_id

(int) (Required) The attendee ID.

$post_id

(int) (Required) The event/post ID.


Top ↑

Source

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

	public function update_attendee_data( $data, $order_id, $event_id ) {
		$user_id = get_current_user_id();

		$ticket_orders    = $this->tickets_view->get_post_ticket_attendees( $event_id, $user_id );
		$ticket_order_ids = wp_list_pluck( $ticket_orders, 'order_id' );

		// This makes sure we don't save attendees for orders that are not from this current user and event
		if ( ! in_array( $order_id, $ticket_order_ids ) ) {
			return;
		}

		$attendee = array();

		// Get the Attendee Data, it's important for testing
		foreach ( $ticket_orders as $test_attendee ) {
			if ( $order_id !== $test_attendee['order_id'] ) {
				continue;
			}

			$attendee = $test_attendee;
		}

		$attendee_email        = empty( $data['email'] ) ? null : sanitize_email( $data['email'] );
		$attendee_email        = is_email( $attendee_email ) ? $attendee_email : null;
		$attendee_full_name    = empty( $data['full_name'] ) ? null : sanitize_text_field( $data['full_name'] );
		$attendee_optout       = empty( $data['optout'] ) ? false : (bool) $data['optout'];

		$product_id  = $attendee['product_id'];

		update_post_meta( $order_id, $this->attendee_optout_key, (bool) $attendee_optout );

		if ( ! is_null( $attendee_full_name ) ) {
			update_post_meta( $order_id, $this->full_name, $attendee_full_name );
		}

		if ( ! is_null( $attendee_email ) ) {
			update_post_meta( $order_id, $this->email, $attendee_email );
		}
	}

Top ↑

Changelog

Changelog
Version Description
4.7 Introduced.