Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat - Add support for series pass with seating tickets #3307

Draft
wants to merge 13 commits into
base: feat/slr-support
Choose a base branch
from
26 changes: 3 additions & 23 deletions src/Tickets/Flexible_Tickets/Series_Passes/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -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', [
Expand Down Expand Up @@ -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
);
}

/**
Expand All @@ -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',
Expand Down Expand Up @@ -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
);
}

/**
Expand Down Expand Up @@ -343,7 +323,7 @@ public function classic_editor_ticket_items( ?string $html, string $file, $name,

return $buffer;
}

/**
* Disables Tickets and RSVPs on recurring events.
*
Expand Down
63 changes: 63 additions & 0 deletions src/Tickets/Seating/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Expand All @@ -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.
Expand Down
1 change: 0 additions & 1 deletion src/views/seating/tickets-block.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
* @var string $inventory The inventory of the tickets.
* @var string $modal_content The content of seat selection modal.
*/

?>

<div class="tribe-common event-tickets tribe-tickets__tickets-wrapper">
Expand Down
Loading