Abstract_REST_Endpoint::get_mapped_orders_from_queue( TECEvent_AutomatorZapierRESTV1Endpointsarray $current_queue, string $empty_code, string $no_valid_code )
Retrieves a list of mapped orders from the specified queue.
Contents
Parameters
- $current_queue
-
(<span class="TECEvent_AutomatorZapierRESTV1EndpointsarrayTECEvent_AutomatorZapierRESTV1Endpointsarray<string|">TECEvent_AutomatorZapierRESTV1Endpointsmixed>) (Required) The queue of order IDs to be processed.
- $empty_code
-
(string) (Required) The code to return if the current queue is empty.
- $no_valid_code
-
(string) (Required) The code to return if no valid orders are found.
Return
(TECEvent_AutomatorZapierRESTV1Endpointsarray<string|TECEvent_AutomatorZapierRESTV1Endpointsmixed>) An array of mapped attendees or an array with a specific 'id' code.
Source
File: src/Common/Event_Automator/Zapier/REST/V1/Endpoints/Abstract_REST_Endpoint.php
public function get_mapped_orders_from_queue( $current_queue, string $empty_code, string $no_valid_code ) {
if ( empty( $current_queue ) ) {
return [ [ 'id' => $empty_code ] ];
}
$orders = [];
foreach ( $current_queue as $next_order_id ) {
// Ensure that $next_order_id is numeric before typecasting to integer.
if ( ! is_numeric( $next_order_id ) ) {
continue;
}
$next_order_id = (int) $next_order_id;
$provider = tribe_tickets_get_ticket_provider( $next_order_id );
if ( empty( $provider->orm_provider ) && class_exists( 'Tribe__Tickets_Plus__Commerce__EDD__Main', false ) && function_exists( 'edd_get_order' ) ) {
$next_order = edd_get_order( $next_order_id );
if ( $next_order instanceof \EDD\Orders\Order ) {
/** @var \Tribe__Tickets_Plus__Commerce__EDD__Main $commerce_edd */
$provider = tribe( 'tickets-plus.commerce.edd' );
}
}
if ( ! $provider instanceof Tribe__Tickets__Tickets ) {
continue;
}
if ( $provider->orm_provider === 'woo' ) {
$next_order = $this->get_woo_order_by_id( $next_order_id );
} elseif ( $provider->orm_provider === 'edd' ) {
$next_order = $this->get_edd_order_by_id( $next_order_id );
} elseif ( $provider->orm_provider === 'tickets-commerce' ) {
$next_order = $this->get_tc_order_by_id( $next_order_id );
}
if ( empty( $next_order ) ) {
continue;
}
$orders[] = $next_order;
}
return ! empty( $orders ) ? $orders : [ [ 'id' => $no_valid_code ] ];
}
Changelog
| Version | Description |
|---|---|
| 6.0.0 | Introduced. |