Tribe__Tickets__REST__V1__Post_Repository::get_ticket_global_id( int $ticket_id, string $provider_class = null )
Returns a ticket global ID.
Contents
If not set/updated for the attendee than the method will generate/update it.
Parameters
- $ticket_id
-
(int) (Required) The ticket ID.
- $provider_class
-
(string) (Optional) The provider class.
Default value: null
Return
(bool|string)
Source
File: src/Tribe/REST/V1/Post_Repository.php
public function get_ticket_global_id( $ticket_id, $provider_class = null ) {
$existing = get_post_meta( $ticket_id, $this->global_id_key, true );
if ( ! empty( $existing ) ) {
return $existing;
}
if ( null === $provider_class ) {
/** @var Tribe__Tickets__Tickets $provider */
$provider = tribe_tickets_get_ticket_provider( $ticket_id );
if ( ! $provider instanceof Tribe__Tickets__Tickets ) {
return false;
}
$provider_class = get_class( $provider );
}
$generator = new Tribe__Tickets__Global_ID();
$generator->origin( home_url() );
$type = $this->get_provider_slug( $provider_class );
$generator->type( $type );
$global_id = $generator->generate( array(
'type' => $type,
'id' => $ticket_id,
) );
update_post_meta( $ticket_id, $this->global_id_key, $global_id );
return $global_id;
}
Changelog
| Version | Description |
|---|---|
| 4.8 | Introduced. |