diff --git a/src/Tickets/Flexible_Tickets/Series_Passes/Base.php b/src/Tickets/Flexible_Tickets/Series_Passes/Base.php index 658e1cec4c..a82e1fe320 100644 --- a/src/Tickets/Flexible_Tickets/Series_Passes/Base.php +++ b/src/Tickets/Flexible_Tickets/Series_Passes/Base.php @@ -89,7 +89,7 @@ protected function do_register(): void { $this, 'classic_editor_ticket_items' ], 10, 5 ); - + // Remove the warning about Tickets added to a Recurring Event. $ticket_admin_notices = tribe( 'tickets.admin.notices' ); remove_action( 'admin_init', [ @@ -163,16 +163,6 @@ protected function do_register(): void { $this, 'show_series_link_after_ticket_type_title' ], 10, 3 ); - - add_filter( - 'tribe_template_pre_html:tickets/admin-views/editor/panel/settings-button', - [ - $this, - 'remove_settings_button_from_classic_metabox', - ], - 10, - 5 - ); } /** @@ -193,7 +183,7 @@ public function unregister(): void { $this, 'classic_editor_ticket_items' ] ); - + // Restore the warning about Tickets added to a Recurring Event. $ticket_admin_notices = tribe( 'tickets.admin.notices' ); if ( ! has_action( 'admin_init', @@ -275,16 +265,6 @@ public function unregister(): void { $this, 'show_series_link_after_ticket_type_title' ], 10, 3 ); - - remove_filter( - 'tribe_template_pre_html:tickets/admin-views/editor/panel/settings-button', - [ - $this, - 'remove_settings_button_from_classic_metabox', - ], - 10, - 5 - ); } /** @@ -343,7 +323,7 @@ public function classic_editor_ticket_items( ?string $html, string $file, $name, return $buffer; } - + /** * Disables Tickets and RSVPs on recurring events. * diff --git a/src/Tickets/Seating/Frontend.php b/src/Tickets/Seating/Frontend.php index 1be9705897..ef5c0650f5 100644 --- a/src/Tickets/Seating/Frontend.php +++ b/src/Tickets/Seating/Frontend.php @@ -13,6 +13,7 @@ use TEC\Common\Contracts\Provider\Controller as Controller_Contract; use TEC\Common\lucatume\DI52\Container; use TEC\Common\StellarWP\Assets\Asset; +use TEC\Tickets\Commerce\Tickets_View; use TEC\Tickets\Seating\Admin\Ajax; use TEC\Tickets\Seating\Frontend\Session; use TEC\Tickets\Seating\Frontend\Timer; @@ -185,6 +186,8 @@ public function print_tickets_block( $html, $file, $name, $template, $context ): ], false ); + + $html .= $this->render_non_asc_ticket_form( $post_id ); /** * Filters the contents of the Tickets block. @@ -198,6 +201,66 @@ public function print_tickets_block( $html, $file, $name, $template, $context ): return $html; } + + /** + * Renders the non-ASC ticket form. + * + * @since TBD + * + * @param int $post_id The post ID. + * + * @return string The HTML of the non-ASC ticket form. + */ + public function render_non_asc_ticket_form( int $post_id ): string { + $has_non_asc_tickets = tribe_tickets() + ->where( 'event', $post_id ) + ->where( 'meta_not_exists', Meta::META_KEY_SEAT_TYPE ) + ->count() > 0; + + if ( $has_non_asc_tickets ) { + add_filter( 'tribe_template_context:tickets/v2/tickets', [ $this, 'exclude_asc_tickets' ] ); + remove_filter( 'tribe_template_pre_html:tickets/v2/tickets', [ $this, 'print_tickets_block' ] ); + add_filter( 'tribe_template_pre_html:tickets/v2/tickets/title', '__return_false' ); + + $html = tribe( Tickets_View::class )->get_tickets_block( $post_id, false ); + + add_filter( 'tribe_template_pre_html:tickets/v2/tickets', [ $this, 'print_tickets_block' ] ); + remove_filter( 'tribe_template_context:tickets/v2/tickets', [ $this, 'exclude_asc_tickets' ] ); + remove_filter( 'tribe_template_pre_html:tickets/v2/tickets/title', '__return_false' ); + + return $html; + } + + return ''; + } + + /** + * Excludes ASC tickets from the context. + * + * @since TBD + * + * @param array $context The context data passed to the template. + * + * @return array The context data passed to the template. + */ + public function exclude_asc_tickets( $context ): array { + if ( ! isset( $context['tickets_on_sale'] ) ) { + return $context; + } + + $non_asc_tickets = array_filter( + $context['tickets_on_sale'], + function ( $ticket ) { + return ! get_post_meta( $ticket->ID, Meta::META_KEY_SEAT_TYPE, true ); + } + ); + + // Update context with non asc tickets. + $context['tickets'] = $non_asc_tickets; + $context['tickets_on_sale'] = $non_asc_tickets; + + return $context; + } /** * Adjusts the event's ticket capacity to consider seating. diff --git a/src/views/seating/tickets-block.php b/src/views/seating/tickets-block.php index f2785d6e22..3d8f0de683 100644 --- a/src/views/seating/tickets-block.php +++ b/src/views/seating/tickets-block.php @@ -13,7 +13,6 @@ * @var string $inventory The inventory of the tickets. * @var string $modal_content The content of seat selection modal. */ - ?>