Tribe__Tickets__Metabox::ajax_ticket_edit( bool $return_value = false )

Returns the data from a single ticket to populate the edit form.


Parameters

$return_value

(bool) (Optional) flags whether to JSON output directly or return results.

Default value: false


Top ↑

Return

(void|WP_Error|array) The results depending on $return_value param, WP_Error if something went wrong.


Top ↑

Source

File: src/Tribe/Metabox.php

	public function ajax_ticket_edit() {
		$post_id = absint( tribe_get_request_var( 'post_id', 0 ) );

		if ( ! $post_id ) {
			wp_send_json_error( esc_html__( 'Invalid parent Post', 'event-tickets' ) );
		}

		$ticket_id = absint( tribe_get_request_var( 'ticket_id', 0 ) );

		if ( ! $ticket_id ) {
			wp_send_json_error( esc_html__( 'Invalid Ticket', 'event-tickets' ) );
		}

		/**
		 * This is needed because a provider can implement a dynamic set of fields.
		 * Each provider is responsible for sanitizing these values.
		 */
		$data = wp_parse_args( tribe_get_request_var( array( 'data' ), array() ), array() );

		if ( ! $this->has_permission( $post_id, $_POST, 'edit_ticket_nonce' ) ) {
			wp_send_json_error( esc_html__( 'Failed to Edit the Ticket, Refresh the Page to try again.', 'event-tickets' ) );
		}

		$provider = tribe_tickets_get_ticket_provider( $ticket_id );

		if ( ! $provider ) {
			wp_send_json_error( esc_html__( 'Commerce Module invalid', 'event-tickets' ) );
		}

		// Get the Ticket Object
		$ticket = $provider->get_ticket( $post_id, $ticket_id );
		$return = $this->get_panels( $post_id, $ticket_id );

		/**
		 * Provides an opportunity for final adjustments to the data used to populate
		 * the edit-ticket form.
		 *
		 * @param array $return     Data for the JSON response
		 * @param int   $post_id    Post ID
		 * @param int   $ticket_id  Ticket ID
		 */
		$return = (array) apply_filters( 'tribe_events_tickets_ajax_ticket_edit', $return, $post_id, $ticket_id );

		wp_send_json_success( $return );
	}

Top ↑

Changelog

Changelog
Version Description
5.5.7 Added optional parameter to return values instead of echoing directly.
4.6.2
4.12.3 Update detecting ticket provider to account for possibly inactive provider. Remove unused vars.
4.10.9 Introduced.