Hi there!
I’ve recently moved to sage for new projects and it works amazing! great job everyone!
Currently I’m rewriting an older project from Underscores to Sage and I can’t get the following to work.
On the website I use a few customised Tribe Events Calendar functions to get the amount of tickets left. I added a new config file /lib/tribe.php to define the function with the namespace Roots\Sage\Tribe. If anyone knows how to fix this, it’s probably a basic PHP thing I’m missing… Thanks!
function tribe_events_single_ticket_soldout( $event = null ) {
if ( null === ( $event = tribe_tickets_parent_post( $event ) ) ) {
return false;
}
$some_have_soldout = false;
foreach ( Tribe__Tickets__Tickets::get_all_event_tickets( $event->ID ) as $ticket ) {
if ( ! $some_have_soldout && 0 == $ticket->stock() ) {
$some_have_soldout = true;
}
}
return $some_have_soldout;
}
add_action('', __NAMESPACE__ . '\\tribe_events_single_ticket_soldout');
The function is called on several places but gives an error because of this line:
foreach ( Tribe__Tickets__Tickets::get_all_event_tickets( $event->ID ) as $ticket ) {}
Because the Tribe__Tickets__Tickets
isn’t part of the namespace or something.
The full error:
Fatal error: Uncaught Error: Class 'Roots\Sage\Tribe\Tribe__Tickets__Tickets' not found in /Applications/AMPPS/www/jam/wp-content/themes/alloy-sage/lib/tribe.php:58 Stack trace: #0 /Applications/AMPPS/www/jam/wp-content/themes/alloy-sage/tribe-events/list/single-event.php(30): Roots\Sage\Tribe\tribe_events_single_ticket_surgeon_quant() #1 /Applications/AMPPS/www/jam/wp-content/plugins/the-events-calendar/src/functions/template-tags/general.php(131): include('/Applications/A...') #2 /Applications/AMPPS/www/jam/wp-content/themes/alloy-sage/tribe-events/list/loop.php(38): tribe_get_template_part('list/single', 'event') #3 /Applications/AMPPS/www/jam/wp-content/plugins/the-events-calendar/src/functions/template-tags/general.php(131): include('/Applications/A...') #4 /Applications/AMPPS/www/jam/wp-content/themes/alloy-sage/tribe-events/list/content.php(26): tribe_get_template_part('list/loop') #5 /Applications/AMPPS/www/jam/wp-content/plugins/the-events-calendar/src/functions/template-tags/general.php(131): include('/Applicati in /Applications/AMPPS/www/jam/wp-content/themes/alloy-sage/lib/tribe.php on line 58