Support

Home Forums Event Espresso Premium Error message showing on table page

Error message showing on table page

Posted: July 11, 2018 at 11:38 am


mpurse

July 11, 2018 at 11:38 am

We are seeing this error message on any page where we are showing the table layout:

Warning: array_shift() expects parameter 1 to be array, string given in /home/sites/3b/6/680238a742/public_html/wp-content/themes/goodlife/espresso-events-table-template.php on line 97

Any ideas? Thanks.


Tony

  • Support Staff

July 11, 2018 at 11:43 am

Hi there,

Can you post the contents of /themes/goodlife/espresso-events-table-template.php to a gist or pastebin and post the URL here so we can take a look?


mpurse

July 11, 2018 at 11:44 am

Here’s the URL: https://www.thegoodlifecentre.co.uk/workshops/


mpurse

July 11, 2018 at 11:47 am

Here’s the gist: https://gist.github.com/mpurse/a49a1f50fa01a82877f435582bc09a61


Tony

  • Support Staff

July 11, 2018 at 12:03 pm

That template looks different from the output on your page, for example the table on the page has a Price column (which I think it’s the problem) but the code you provided doesn’t pull the price into the table.

Can you double check that is the correct code, from the template in your theme. It looks like it’s the default template.


Josh

  • Support Staff

July 11, 2018 at 12:05 pm

Can you double check and make sure you posted the correct template? The reason I ask is because the page on your site shows 10 columns in the table, but the code you posted only has 4 columns in the table. Also, line 97 of the template you posted here does not call array_shift().


mpurse

July 11, 2018 at 12:07 pm

Sorry, developer on vacation and I am out of my depth. I think I have updated it.


Josh

  • Support Staff

July 11, 2018 at 12:23 pm

You did, thanks. So the problem is in the customized part of the template starting on line 94 where the developer added:

// grab array of EE_Ticket objects for event
$tickets = espresso_event_tickets_available( $post->ID, FALSE, FALSE );
// grab first ticket from array
$ticket = array_shift( $tickets );

The espresso_event_tickets_available() function returns a string, not an array. So that explains why you’re seeing a warning that says “Warning: array_shift() expects parameter 1 to be array, string given”.

The way forward will be change the custom code to use a helper method like
EEH_Event_View::event_tickets_available instead, and it will also help avoid errors if they can add some additional checks on the $tickets variable to make sure it’s an array. e.g.

if ( is_array( $tickets ) && ! empty( $tickets )) {
// do tickets stuff here
}


mpurse

July 11, 2018 at 12:27 pm

Excellent, thanks so much!


Tony

  • Support Staff

July 11, 2018 at 12:39 pm

Just to note you have what I assume is the same problem within:

Warning: array_shift() expects parameter 1 to be array, string given in /themes/goodlife/single-espresso_events.php on line 100

When viewing the single event page and the tickets are sold out:

https://www.thegoodlifecentre.co.uk/events/willow-basket-making-15/
(Scroll down)

The support post ‘Error message showing on table page’ 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.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3

Documentation for Event Espresso 4

Status: closed

Updated by  Tony 2 months, 2 weeks ago ago

Topic Tags

Tagged: 

Notifications

This topic is:
pending
Do NOT follow this link or you will be banned from the site!