Skip to content

Commit

Permalink
Merge pull request #3511 from the-events-calendar/fix/init-of-tc-module
Browse files Browse the repository at this point in the history
Fix init of TC module
  • Loading branch information
dpanta94 authored Jan 29, 2025
2 parents 0569d6d + 7d9aefd commit b1635eb
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 4 deletions.
4 changes: 4 additions & 0 deletions changelog/fix-init-of-tc-module
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: patch
Type: tweak

Init TicketsCommerce Module as soon as possible. [ETP-972]
6 changes: 3 additions & 3 deletions src/Tickets/Commerce/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,6 @@ protected function add_actions() {
// Compatibility Hooks
add_action( 'init', [ $this, 'register_event_compatibility_hooks' ] );

add_action( 'tribe_common_loaded', [ $this, 'load_commerce_module' ] );

add_action( 'template_redirect', [ $this, 'do_cart_parse_request' ] );
add_action( 'template_redirect', [ $this, 'do_checkout_parse_request' ] );

Expand Down Expand Up @@ -482,9 +480,11 @@ public function filter_payments_tab_settings( $settings ) {
* Initializes the Module Class.
*
* @since 5.1.9
*
* @deprecated TBD
*/
public function load_commerce_module() {
$this->container->make( Module::class );
_deprecated_function( __METHOD__, 'TBD' );
}

/**
Expand Down
3 changes: 3 additions & 0 deletions src/Tickets/Commerce/Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ public function register() {
$this->container->singleton( Notice_Handler::class );

$this->container->singleton( Module::class );
// We need to init for the registration as a module to take place early.
$this->container->get( Module::class );

$this->container->singleton( Attendee::class );
$this->container->singleton( Order::class );
$this->container->singleton( Ticket::class );
Expand Down
13 changes: 13 additions & 0 deletions tests/commerce_integration/_Load/CommerceModuleLoaded_Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace ET;

use Codeception\TestCase\WPTestCase;
use Tribe__Tickets__Tickets as Tickets;
use TEC\Tickets\Commerce\Module;

class CommerceModuleLoaded_Test extends WPTestCase {
public function test_commerce_module_is_loaded_early() {
$this->assertArrayHasKey( Module::class, Tickets::modules() );
}
}
1 change: 0 additions & 1 deletion tests/commerce_integration/_bootstrap.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?php

use \TEC\Tickets\Commerce\Provider as Commerce_Provider;
use Tribe\Tickets\Promoter\Triggers\Dispatcher;

$tec_support = dirname( __DIR__, 3 ) . '/the-events-calendar/tests/_support';
Codeception\Util\Autoload::addNamespace( 'Tribe\Events\Test', $tec_support );
Expand Down

0 comments on commit b1635eb

Please sign in to comment.