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

Bucket - Woo seating integration #3562

Open
wants to merge 52 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
222a2f4
replace check with compatibility method
rafsuntaskin Nov 27, 2024
38aed6a
applyFilter to allowed providers list
rafsuntaskin Nov 27, 2024
35ec545
fix typo
rafsuntaskin Nov 27, 2024
146b9fe
tests updated
rafsuntaskin Nov 27, 2024
53b2742
Merge branch 'release/T24.hydra' into feat/create-woo-seating-tickets
codingmusician Dec 4, 2024
f87ef1d
Merge branch 'bucket/woo-seating-integration' into feat/create-woo-se…
rafsuntaskin Dec 17, 2024
6a6032f
allow ajax calls
rafsuntaskin Jan 1, 2025
cfcd606
use common attendee id to fetch meta
rafsuntaskin Jan 9, 2025
d868d85
allow all providers
rafsuntaskin Jan 13, 2025
2f70b41
Merge branch 'bucket/woo-seating-integration' into feat/create-woo-se…
rafsuntaskin Jan 13, 2025
8021c5f
phpcbf
rafsuntaskin Jan 13, 2025
89439ed
skip rsvp provider
rafsuntaskin Jan 13, 2025
edc2df8
fix typo
rafsuntaskin Jan 13, 2025
2342865
updated to new method
rafsuntaskin Jan 13, 2025
5f72e2b
phpcbf
rafsuntaskin Jan 13, 2025
43b7197
remove admin check for method to check data
rafsuntaskin Jan 15, 2025
00ca058
add filter for ticket data
rafsuntaskin Jan 16, 2025
717dfaf
Merge pull request #3509 from the-events-calendar/sync/to-master
rafsuntaskin Jan 24, 2025
0421b6e
removed woo compatibility notice
rafsuntaskin Jan 29, 2025
30bb208
wrap with tribe common
rafsuntaskin Feb 5, 2025
0b86229
use div to generalize
rafsuntaskin Feb 5, 2025
33476cc
update styles to generalize
rafsuntaskin Feb 5, 2025
10ee80b
update usages of isInterruptable
rafsuntaskin Feb 5, 2025
8e4e2a7
updated filter to array
rafsuntaskin Feb 5, 2025
a69e0bc
Merge branch 'bucket/woo-seating-integration' into feat/create-woo-se…
rafsuntaskin Feb 5, 2025
b6095e5
phpcbf
rafsuntaskin Feb 6, 2025
0d429bd
Merge branch 'feat/create-woo-seating-tickets' into feat/reservation-…
rafsuntaskin Feb 6, 2025
c61eaa8
snapshots updated
rafsuntaskin Feb 6, 2025
06b755d
more snapshots updated
rafsuntaskin Feb 6, 2025
aa8cfe9
jest tests updated
rafsuntaskin Feb 6, 2025
a7ed244
snapshots updated
rafsuntaskin Feb 6, 2025
ddf5aa2
jest snapshots updated
rafsuntaskin Feb 6, 2025
73a25b6
updated jest snapshots again
rafsuntaskin Feb 6, 2025
b7dbdb0
Merge pull request #3481 from the-events-calendar/feat/create-woo-sea…
rafsuntaskin Feb 6, 2025
1c7d445
Merge branch 'bucket/woo-seating-integration' into feat/reservation-t…
rafsuntaskin Feb 6, 2025
d6ca060
tests updated conflicted snapshots
rafsuntaskin Feb 6, 2025
34bbeb4
Merge branch 'master' into task/merge-forward-master-to-bucket/woo-se…
actions-user Feb 11, 2025
5f8eea3
Merge pull request #3548 from the-events-calendar/task/merge-forward-…
rafsuntaskin Feb 11, 2025
33e29f1
Merge branch 'bucket/woo-seating-integration' into feat/reservation-t…
rafsuntaskin Feb 11, 2025
ab4e445
use generic currency format
rafsuntaskin Feb 11, 2025
9470ed9
generalize seat type info
rafsuntaskin Feb 12, 2025
10a61cf
phpcbf
rafsuntaskin Feb 12, 2025
19c1e08
Apply suggestions from code review
rafsuntaskin Feb 12, 2025
8840515
remove unused code
rafsuntaskin Feb 12, 2025
ecd81c8
fix typo
rafsuntaskin Feb 12, 2025
5be9aa1
doc block updated
rafsuntaskin Feb 12, 2025
4f6b015
tests snapshots updated
rafsuntaskin Feb 12, 2025
0949b75
Merge branch 'feat/reservation-timer-integration' into feat/currency-…
rafsuntaskin Feb 12, 2025
29e61d4
Merge pull request #3552 from the-events-calendar/feat/currency-forma…
rafsuntaskin Feb 12, 2025
47034dc
Merge pull request #3528 from the-events-calendar/feat/reservation-ti…
rafsuntaskin Feb 12, 2025
828282d
Merge branch 'master' into task/merge-forward-master-to-bucket/woo-se…
actions-user Feb 13, 2025
3dd21c9
Merge pull request #3561 from the-events-calendar/task/merge-forward-…
rafsuntaskin Feb 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 0 additions & 49 deletions src/Tickets/Seating/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ public function unregister(): void {
$assets->remove( 'tec-tickets-seating-admin-layout-edit-style' );

remove_action( 'admin_menu', [ $this, 'add_submenu_page' ], 15 );
remove_action( 'admin_init', [ $this, 'register_woo_incompatibility_notice' ] );
remove_filter( 'tec_tickets_find_ticket_type_host_posts_query_args', [ $this, 'exclude_asc_events_from_candidates_from_moving_tickets_to' ] );

// Remove the hooks related to the seating meta data duplication.
Expand Down Expand Up @@ -151,7 +150,6 @@ protected function do_register(): void {
$this->reqister_layout_edit_assets();

add_action( 'admin_menu', [ $this, 'add_submenu_page' ], 15 );
add_action( 'admin_init', [ $this, 'register_woo_incompatibility_notice' ] );
add_filter( 'tec_tickets_find_ticket_type_host_posts_query_args', [ $this, 'exclude_asc_events_from_candidates_from_moving_tickets_to' ] );

// Add the hooks related to the seating meta data duplication.
Expand Down Expand Up @@ -252,53 +250,6 @@ public function exclude_asc_events_from_candidates_from_moving_tickets_to( array
return $query_args;
}

/**
* Registers Seating incompatibility notice with WooCommerce.
*
* @since 5.16.0
*
* @return void The notice is registered.
*/
public function register_woo_incompatibility_notice() {
$message = sprintf(
// Translators: %1$s and %2$s are opening/closing p tags, %3$s and %4$s are opening/closing a tags.
esc_html__( '%1$sTickets with assigned seating can only be created when selling with %3$sTickets Commerce%4$s. Support for WooCommerce sales will be included in a future release.%2$s', 'event-tickets' ),
'<p>',
'</p>',
'<a href="' . esc_url( tribe( Settings::class )->get_url( [ 'tab' => 'payments' ] ) ) . '">',
'</a>'
);

$filter_callback = static fn() => [];
$add_filter = static fn() => add_filter( 'tribe_is_post_type_screen_post_types', $filter_callback );
$remove_filter = static fn() => remove_filter( 'tribe_is_post_type_screen_post_types', $filter_callback );

$screen_ids = [
'toplevel_page_tec-tickets',
'tickets_page_tec-tickets-attendees',
'edit-tec_tc_order',
'tickets_page_tec-tickets-settings',
'tickets_page_tec-tickets-help',
'tickets_page_tec-tickets-troubleshooting',
'edit-ticket-meta-fieldset',
'tickets_page_tec-tickets-seating',
];
tribe_notice(
'seating-incompatible-with-woo',
$message,
[
'dismiss' => true,
'type' => 'warning',
],
static function () use ( $add_filter, $remove_filter, $screen_ids ) {
$add_filter();
$result = function_exists( 'WC' ) && Admin_Helper::instance()->is_screen( $screen_ids );
$remove_filter();
return $result;
}
);
}

/**
* Registers the assets used by the Seating Maps tab.
*
Expand Down
41 changes: 27 additions & 14 deletions src/Tickets/Seating/Frontend.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
use TEC\Common\Contracts\Provider\Controller as Controller_Contract;
use TEC\Common\lucatume\DI52\Container;
use TEC\Common\Asset;
use TEC\Tickets\Commerce\Utils\Currency;
use TEC\Tickets\Commerce\Utils\Value;
use Tribe__Tickets__Commerce__Currency;
use TEC\Tickets\Seating\Admin\Ajax;
use TEC\Tickets\Seating\Frontend\Session;
use TEC\Tickets\Seating\Frontend\Timer;
Expand Down Expand Up @@ -169,13 +168,14 @@ public function print_tickets_block( $html, $file, $name, $template, $context ):
$prices = array_keys( $prices );

$inventory = $this->get_events_ticket_capacity_for_seating( $post_id );

$cost_range = count( $prices ) === 1 ?
tribe_format_currency( $prices[0], $post_id ) :
tribe_format_currency( min( $prices ), $post_id )

/** @var Tribe__Tickets__Commerce__Currency $currency */
$currency = tribe( 'tickets.commerce.currency' );

$cost_range = count( $prices ) === 1 ? $currency->get_formatted_currency_with_symbol( $prices[0], $post_id, $provider, false ) :
$currency->get_formatted_currency_with_symbol( min( $prices ), $post_id, $provider, false )
. ' - '
. tribe_format_currency( max( $prices ), $post_id );

. $currency->get_formatted_currency_with_symbol( max( $prices ), $post_id, $provider, false );

$timeout = $this->container->get( Timer::class )->get_timeout( $post_id );

Expand Down Expand Up @@ -275,7 +275,8 @@ private function get_seat_selection_modal_content( int $post_id, int $timeout ):
/** @var \Tribe\Dialog\View $dialog_view */
$dialog_view = tribe( 'dialog.view' );
$provider = Tickets::get_event_ticket_provider_object( $post_id );
/** @var \Tribe__Tickets__Commerce__Currency $currency */

/** @var Tribe__Tickets__Commerce__Currency $currency */
$currency = tribe( 'tickets.commerce.currency' );
$content = $this->template->template(
'iframe-view',
Expand Down Expand Up @@ -431,7 +432,7 @@ public function add_seat_selected_labels_per_ticket_attribute( array $attributes
public function get_ticket_block_data( $post_id ): array {
$service_ok = $this->service->get_status()->is_ok();

return [
$data = [
'objectName' => 'dialog_obj_' . self::MODAL_ID,
'modalId' => self::MODAL_ID,
'seatTypeMap' => $service_ok ? $this->build_seat_type_map( $post_id ) : [],
Expand All @@ -449,6 +450,16 @@ public function get_ticket_block_data( $post_id ): array {
'ACTION_CLEAR_RESERVATIONS' => Ajax::ACTION_CLEAR_RESERVATIONS,
'sessionTimeout' => tribe( Timer::class )->get_timeout( $post_id ),
];

/**
* Filters the data to be localized on the ticket block frontend.
*
* @since TBD
*
* @param array<string,mixed> $data The data to be localized on the ticket block frontend.
* @param int $post_id The post ID.
*/
return apply_filters( 'tec_tickets_seating_frontend_ticket_block_data', $data, $post_id );
}

/**
Expand Down Expand Up @@ -501,13 +512,15 @@ public function build_seat_type_map( ?int $post_id = null ): array {
}

/** @var Tickets_Handler $tickets_handler */
$tickets_handler = tribe( 'tickets.handler' );
$formatted_ticket_price = Value::create( $ticket->price )->get_currency();

$tickets_handler = tribe( 'tickets.handler' );

/** @var Tribe__Tickets__Commerce__Currency $currency */
$currency = tribe( 'tickets.commerce.currency' );

$seat_type_map[ $seat_type ]['tickets'][] = [
'ticketId' => $ticket_id,
'name' => $ticket->name,
'price' => $formatted_ticket_price,
'price' => $currency->get_formatted_currency_with_symbol( $ticket->price, $post_id, $provider, false ),
'priceValue' => $ticket->price,
'description' => $ticket->description,
'dateInRange' => $ticket->date_in_range(),
Expand Down
5 changes: 0 additions & 5 deletions src/Tickets/Seating/Frontend/Session.php
Original file line number Diff line number Diff line change
Expand Up @@ -358,11 +358,6 @@ public function confirm_all_reservations( bool $delete_token_session = true ): b
* @return array|null The reservations for the ticket and post.
*/
public function get_post_ticket_reservations( int $post_id = null, int $ticket_id = null ): ?array {
// Bail while in admin side always. There are no reservations in the admin.
if ( is_admin() ) {
return null;
}

if ( ! ( $ticket_id && $post_id && tec_tickets_seating_enabled( $post_id ) ) ) {
return null;
}
Expand Down
10 changes: 5 additions & 5 deletions src/Tickets/Seating/Orders/Attendee.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@

namespace TEC\Tickets\Seating\Orders;

use TEC\Tickets\Commerce\Module;
use Tribe__Main as Common;
use Tribe__Tickets__Attendee_Repository as Attendee_Repository;
use Tribe__Utils__Array as Arr;
Expand All @@ -20,6 +19,7 @@
use WP_Query;
use WP_Post;
use Tribe__Tickets__Ticket_Object as Ticket_Object;
use Tribe__Tickets__RSVP as RSVP_Provider;

/**
* Class Attendee
Expand Down Expand Up @@ -69,11 +69,11 @@ public function render_seat_column( $value, $item, $column ) {
return $value;
}

if ( ! isset( $item['ID'] ) ) {
if ( ! isset( $item['attendee_id'] ) ) {
return '-';
}

$seat_label = get_post_meta( $item['ID'], Meta::META_KEY_ATTENDEE_SEAT_LABEL, true );
$seat_label = get_post_meta( $item['attendee_id'], Meta::META_KEY_ATTENDEE_SEAT_LABEL, true );

if ( ! empty( $seat_label ) ) {
return $seat_label;
Expand Down Expand Up @@ -302,11 +302,11 @@ public function inject_seat_info_in_my_tickets( string $html, Template $template
public function format_many( array $attendees ): array {
$unknown_attendee_name = __( 'Unknown', 'event-tickets' );

// Filter out attendees that are not from the Commerce module.
// Filter out attendees that are from the RSVP provider.
$attendees = array_filter(
$attendees,
static function ( array $attendee ): bool {
return Module::class === $attendee['provider'];
return RSVP_Provider::class !== $attendee['provider'];
}
);

Expand Down
4 changes: 3 additions & 1 deletion src/Tickets/Seating/app/blockEditor/filters.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { addFilter, addAction } from '@wordpress/hooks';
import CapacityForm from './capacity-form';
import { storeName } from './store';
import { currentProviderSupportsSeating } from './store/compatibility';
import { select } from '@wordpress/data';
import Seats from './dashboard-actions/seats';
import { filterCapacityTableMappedProps } from './capacity-table';
Expand Down Expand Up @@ -34,7 +35,8 @@ function filterRenderCapacityForm(renderDefaultForm, { clientId, ticketProvider
return renderDefaultForm;
}

if ( ticketProvider !== "TEC\\Tickets\\Commerce\\Module" && ticketProvider !== 'tc' ) {
// When the provider does not support seating, we render the default form.
if ( ! currentProviderSupportsSeating() ) {
return renderDefaultForm;
}

Expand Down
14 changes: 13 additions & 1 deletion src/Tickets/Seating/app/blockEditor/store/compatibility.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { applyFilters } from '@wordpress/hooks';
import { getTicketProviderFromCommonStore } from './common-store-bridge';

/**
Expand All @@ -14,5 +15,16 @@ import { getTicketProviderFromCommonStore } from './common-store-bridge';
export function currentProviderSupportsSeating() {
const provider = getTicketProviderFromCommonStore();

return 'TEC\\Tickets\\Commerce\\Module' === provider;
/**
* Filter the allowed ticket providers for seating.
*
* @since TBD
*
* @param {string[]} allowedProviders The allowed ticket providers for seating.
*/
let allowedProviders = applyFilters( 'tec.tickets.seating.allowedProviders', [
'TEC\\Tickets\\Commerce\\Module',
] );

return allowedProviders.includes( provider );
}
24 changes: 9 additions & 15 deletions src/Tickets/Seating/app/frontend/session/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,10 +121,12 @@ let watchedCheckoutControls = [];
*
* @since 5.16.0
*
* @type {string}
* @type {string[]}
*/
export const checkoutControlsSelectors =
'.tribe-tickets__commerce-checkout-form-submit-button, .tribe-tickets__commerce-checkout-paypal-buttons button';
export const checkoutControlsSelectors = [
'.tribe-tickets__commerce-checkout-form-submit-button',
'.tribe-tickets__commerce-checkout-paypal-buttons button',
];

/**
* Sets the interruptable flag.
Expand Down Expand Up @@ -417,10 +419,6 @@ async function getInterruptDialogElement() {
* @return {void} The timer is interrupted.
*/
async function interrupt() {
if (!isInterruptable()) {
return;
}

setIsInterruptable(true);

getTimerElements().forEach((timerElement) => {
Expand Down Expand Up @@ -482,10 +480,6 @@ export function beaconInterrupt() {
* @return {void}
*/
function startCountdownLoop(secondsLeft) {
if (!isInterruptable()) {
return;
}

if (secondsLeft <= 0) {
interrupt();

Expand Down Expand Up @@ -518,7 +512,7 @@ function startCountdownLoop(secondsLeft) {
* @return {void}
*/
function startHealthCheckLoop() {
if (isExpired() || !isInterruptable()) {
if ( isExpired() ) {
return;
}

Expand All @@ -538,7 +532,7 @@ function startHealthCheckLoop() {
* @return {Promise<void>} A promise that will resolve when the request is completed.
*/
export async function syncWithBackend() {
if (isExpired() || getTimerElements().length === 0 || !isInterruptable()) {
if ( isExpired() || getTimerElements().length === 0 ) {
return;
}

Expand Down Expand Up @@ -823,15 +817,15 @@ export function watchCheckoutControls() {
*
* @since 5.16.0
*
* @type {string} The `querySeelctorAll` selectors used to find the checkout controls on the page.
* @type {string[]} The `querySelectorAll` selectors used to find the checkout controls on the page.
*/
const filteredCheckoutControls = applyFilters(
'tec.tickets.seating.frontend.session.checkoutControls',
checkoutControlsSelectors
);

const checkoutControlElements = targetDom.querySelectorAll(
filteredCheckoutControls
filteredCheckoutControls.join(', ')
);

checkoutControlElements.forEach((checkoutControlElement) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export function InterruptDialogComponent(props) {
<div class="tribe-tickets-seating__interrupt-dialog" role="dialog">
<div class="tribe-tickets-seating__interrupt-header">
<div class="dashicons dashicons-clock"></div>
<p class="tribe-tickets-seating__interrupt-title">{title}</p>
<div class="tribe-tickets-seating__interrupt-title">{title}</div>
</div>
<div class="tribe-dialog__content tribe-modal__content tribe-tickets-seating__interrupt-content">{content}</div>
<div class="tribe-tickets-seating__interrupt-footer">
Expand Down
4 changes: 2 additions & 2 deletions src/Tickets/Seating/app/frontend/session/style.pcss
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
.event-tickets .tec-tickets-seating__timer {
.tribe-common .tec-tickets-seating__timer {
&.tec-tickets-seating__timer--hidden {
display: none;
}
Expand Down Expand Up @@ -41,7 +41,7 @@
}
}

.event-tickets .tec-tickets-seating__back-to-event {
.tec-tickets-seating__back-to-event {
margin-top: var(--tec-spacer-2);

&--link{
Expand Down
9 changes: 8 additions & 1 deletion src/Tribe/Commerce/Cart.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,16 @@ public function hook() {
* @since 4.11.0
*/
public function process_cart() {
if ( empty( $_POST['tribe_tickets_ar'] ) || is_admin() ) {
$has_tickets = tec_get_request_var( 'tribe_tickets_ar' );

if ( empty( $has_tickets ) ) {
return;
}

if ( ! wp_doing_ajax() && is_admin() ) {
return;
}


$data = $_POST;

Expand Down
Loading
Loading