Support

Home Forums Event Espresso Premium Tickets not shown correctly

Tickets not shown correctly

Posted: April 4, 2024 at 1:11 am


greyowl

April 4, 2024 at 1:11 am

I have multiple tickets for some events (courses). When the event is displayed, only one ticket is shown. When the customer clicks “Anmelden” (Register), all the tickets are presented but with an additional optional (grey) link, which distorts the display.
Try Kurs 32 or one of the fide-Tests on https://www.lernen-im-quartier.ch/ to see the problem.


Sam

  • Support Staff

April 4, 2024 at 4:16 am

Hi there,

Are you referring to the details showing under “show details” dropdown?

If so then can you please let me know what exact issue you are facing there, as I can see the dropdown showing the details fine.

Also, please share a screenshot of the issue. You can use https://www.loom.com/ to share the screenshot.


greyowl

April 4, 2024 at 9:02 am

Kurs 32 has 2 differently priced tickets but when I click the “+” in the course list (https://www.lernen-im-quartier.ch/ front page) I only see the second ticket (CHF 600). When I click “Anmelden” (Register) I see both.
Same with fide-Test e.g. on 24.4.2024. It has 3 tickets but only one is shown when I click the “+”.
I’m having trouble with Loom. Can I just send you screen shots?


greyowl

April 4, 2024 at 9:16 am

I think I’ve mastered Loom. Have a look here: https://www.loom.com/share/b6853291e5654254994025b5f062dd7f


Sam

  • Support Staff

April 4, 2024 at 11:32 am

Hi Viktor,

Got what you are referring above, you are facing the issue because there is a limitation of words within the drop-down.

Are you comfortable with editing the core file? Please let us know so that we can guide you with the path to adjust the limit.

Looking forward to helping you.


greyowl

April 4, 2024 at 11:54 am

Are you referring to the template file I use (which I can edit with guidance) or another file?


Tony

  • Support Staff

April 4, 2024 at 4:37 pm

Hi there,

The table view template by Event Espresso does not include the ticket prices on that section by default so I assume you’re using a custom template for the table view toggle template, right?

To help I’m going to need to see the code for that template file as I have no idea how its currently pulling in the tickets to output there.

Can you add the content of that template to something like PasteBin so I can take a look?


greyowl

April 5, 2024 at 12:31 am

Here it is: https://pastebin.com/vyGMvu2t


Tony

  • Support Staff

April 8, 2024 at 6:34 am

There’s a fair bit going on within the template file and some of it is specific to your site so I can’t test it locally, but…

This part stands out:


$tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE ); 
global $wpdb; 
$final_html = "";
if($tickets){
	foreach ($tickets as $key => $v) {
    	// Searching for ticket relationship with ticket id and price id 
    	// tables below contain all data 	
    	$_tkt = $v; 

    		$obj_keys = array(); 
    		foreach ($_tkt as $_k => $v) {
    			$obj_keys[] = $_k; 
    		}
    		$_pr =  $v->prices();
    		$final_html = '';
    		foreach ($_pr as $pk => $p) {
    			$html = ' '.$p->name().' '; 
    			$html .= (empty($p->amount())) ? $p->desc() : $p->pretty_price().' plus ';

    			$final_html .= $html;
    		}
    		$final_html = substr($final_html, 0, -5);

    }
}

Within that code, $final_html (which is what the template uses to output the cost) will always be based on the ‘last’ ticket of the $tickets array because it is in the foreach loop for $tickets. Which mean means every time it loops over the tickets it basically replaces the content from whatever it did on the let’s iteration for the current ticket interation.

It is first initialized outside of the foreach (line 175) with `$final_html = “”;
`

Assigns the individual ticket from within $tickets to $v, to then assign $v to $_tkt which is then looped over as $_k => $v and $_k assign to $obj_keys (which is then never used and I don’t most of that is either).

Prices are pulled from the ticket and assigned to $_pr using:

$_pr = $v->prices();

($v was already the ticket from the original for each so $v, is the EE_Ticket)

Then $final_html = ''; on line 187 ’empties’ the variable by setting it to an empty string within the loop.

Loops over all prices assigned to the individual ticket it is currently working within on within the loop:

foreach ($_pr as $pk => $p) {...}

Which uses $final_html .= $html; on line 193 and concatenates the output…. but then $final_html = substr($final_html, 0, -5); is within the foreach loop for $tickets so in effect it repeats that every time for ever ticket replacing the previous content as it does.

I looks like you are trying to output tickets assigned to a specific price type within your site and looping over a bunch of code on prices to output it in a specific way but it’s replacing itself on each loop which is the reason you are only getting 1 ticket output there.

Drop line 187 and move $final_html = substr($final_html, 0, -5); to be outside of the foreach loop, that should get you a little closer. Then figure out what needs to be done to correct the output from there.

I recommend working through that code to tidy it up further, I’m not sure why your looping over prices within a ticket and not just using the tickets themselves to pull the details you need directly and generate a $final_html from that but then I don’t fully understand the use case here.

The support post ‘Tickets not shown correctly’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso