Tribe__Tickets__Tickets_View::update_tickets()
Update the RSVP and Tickets values for each Attendee.
Source
File: src/Tribe/Tickets_View.php
public function update_tickets() {
$is_correct_page = $this->is_edit_page();
// Now fetch the display and check it
$display = get_query_var( 'eventDisplay', false );
if ( 'tickets' !== $display && ! $is_correct_page ) {
return;
}
if ( empty( $_POST['process-tickets'] ) || ( empty( $_POST['attendee'] ) && empty( $_POST['tribe-tickets-meta'] ) ) ) {
return;
}
$post_id = get_the_ID();
$attendees = ! empty( $_POST['attendee'] ) ? $_POST['attendee'] : array();
/**
* Sort list to handle all not attending first
*
* @todo switch to only wp_list_sort once WordPress 4.7 is minimum supported version
*/
if ( function_exists( 'wp_list_sort' ) ) {
$attendees = wp_list_sort( $attendees, 'order_status', 'ASC', true );
} else {
uasort( $attendees, array( $this, 'sort_attendees' ) );
}
foreach ( $attendees as $order_id => $data ) {
/**
* An Action fired for each one of the Attendees that were posted on the Order Tickets page
*
* @var array $data Infomation that we are trying to save
* @var int $order_id ID of attendee ticket
* @var int $post_id ID of event
*/
do_action( 'event_tickets_attendee_update', $data, $order_id, $post_id );
}
/**
* A way for Meta to be saved, because it's grouped in a different way
*
* @param int $post_id ID of event
*/
do_action( 'event_tickets_after_attendees_update', $post_id );
// After Editing the Values we Update the Transient
Tribe__Post_Transient::instance()->delete( $post_id, Tribe__Tickets__Tickets::ATTENDEES_CACHE );
// If it's not events CPT
$url = $this->get_tickets_page_url( $post_id, ! $is_correct_page );
$url = add_query_arg( 'tribe_updated', 1, $url );
wp_safe_redirect( esc_url_raw( $url ) );
exit;
}
Changelog
| Version | Description |
|---|---|
| 5.8.2 | Introduced. |