Support

Home Forums Event Espresso Premium Condensed Seating Code

Condensed Seating Code

Posted: July 19, 2023 at 11:06 pm

Viewing 7 reply threads


kellyjo

July 19, 2023 at 11:06 pm

There used to be a feature or code that showed how many seats belonged to a single purchaser. It would appear as;

[A Name]
(1 seat)

[B Name]
(2 seats)

https://my.bincdn.com/1117/ee4-full-seats.jpg

I think it used to appear sometime like that back in 2016 EE4 version.

Then it was changed to:

[A Name]
(1 of 2)

[A Name]
(2 of 2)

[B Name]
(1 of 1)

https://my.bincdn.com/1117/ee4-total-seats.jpg

Currently, the second one is how EE4 is displaying, but how do I re-create the first one?


Tony

  • Support Staff

July 20, 2023 at 4:46 am

Hi there,

That is not a feature I can recall being added to Event Espresso, are you sure that wasn’t something custom?

The code to display “X / Y” for registrations was added in 2015, before that was just the ID. We have never referred to the REG_count or REG_total as ‘seats’ because we cover way more use cases than those for ‘seats’ so its a term we don’t use.

Your screenshot is only displaying primary registrants but we display them all.

I’m guessing this was something custom, either via translating the (%1$s / %2$s ) string and just using %2$s for the group size, or hooking in and completely changing out the column content.


kellyjo

July 20, 2023 at 9:14 am

It definitely could have been something custom. I just cannot recall ever adding it. I was just wondering if it was possible to do it, even if it was custom, and where I might find it to actually do it.


kellyjo

July 21, 2023 at 1:15 am

Tony,

You gave me the hint with %1$s / %2$s though it turned out to be %s of %s as I needed to make the modification on the Event Check-in page.

With some help from ChatGPT, I was able to modify the code to go from:

1 of 2
2 of 2
to
2 seats

https://my.bincdn.com/1117/ee4-check-in-seats.jpg


Tony

  • Support Staff

July 21, 2023 at 4:47 am

🙂 Got to love a bit of ChatGPT.

I’m curious as to what it gave you for this, mind sharing? (You can add it in a private reply and I’ll delete it again if preferred)


kellyjo

July 21, 2023 at 9:22 am

Sure Tony. I’m happy to share with others if there is nothing against the policy. If it is, feel free to delete this response.

So in the specific request for this code code, she prints out the Event Check-In page which her staff uses as a check off list to understand how many seats her customers have purchased, but having so many rows in the table was taking up a lot of space and printing out too much paper, so she was wanting a single name of the customer and how many seats they purchased.

As a warning to those who wish to use the code, it is an EE4 core file that was modified so I must put the warning out there to anyone who wishes to use the code:

FOR EVENT ESPRESSO 4 USE ONLY. PLEASE DO NOT ATTEMPT THIS ON A LIVE PRODUCTION WEBSITE UNLESS YOU KNOW WHAT YOU ARE DOING.

File: EE_Event_Registrations_List_Table.class.php

I combed over the Event Check-In code and knew these functions were important:

  • $registration->count();
  • $registration->group_size();
  • %s to %s

Just had to figure out how to use them to produce my desired result!

This is where ChatGPT was most instrumental in helping me figure out what the code was to skip the row. I could skip the column by returning an empty string but it wasn’t removing the row!

/**
 * Display a single row in the table.
 *
 * @param mixed $item The current item (EE_Registration).
 * By overriding the single_row() method, we can control whether a row should be displayed or not. 
 * $registration->count() must be equal to $registration->group_size()
 * return from the method without calling the parent class's single_row() method, effectively skipping the row in the table.
 */
public function single_row($item)
{
    // Check if count is equal to group_size and skip the row if they are equal
    if ($item->count() < $item->group_size()) {
        return;
    }

    parent::single_row($item);
}

Fortunately, EE4 devs were generous to return the higher number in the group first.

The other section of the code that was changed:


 // add group details
 $name_link .= '&nbsp;' . sprintf(
    esc_html__('(%s %s)', 'event_espresso'),
    $registration->count(),
    ($registration->count() === 1) ? 'seat' : 'seats'
);

And of course, since this condensed the seats, EE4 stars the first ticket purchase which is no longer relevant, so this code can be commented out:


//  $name_link    .= $registration->count() === 1
            ? '&nbsp;<sup><div class="dashicons dashicons-star-filled gold-icon"></div></sup>	'
            : ''; 

I do hope this feature can be built into EE4 to give a more condensed version of the registration / event check-in list page, but this seems to have done the trick for my needs!


kellyjo

July 21, 2023 at 11:14 am

In addition for the printing code (ctrl+p on the Event Check-In page), this cuts out all the unnecessary bits that you need on a regular desktop or mobile phone, but not when printing.

Again, AS A WARNING TO ANYONE USING THIS CODE, you will need to add this to a functions.php file, which EE4 Support Staff is very adamant about NOT editing. Thus, they always provide this link, as tinkering in the functions.php can break your website:

https://eventespresso.com/wiki/create-site-specific-plugin-wordpress-site/

I urge you to stay out of your theme’s functions.php as any theme updates will remove all your hard work or just break your website, so do yourself a huge favor and create a custom functions file or download a plugin. There are several available with some designed to ensure that even if there is something wrong with your code, your website won’t break!

PLEASE DO NOT TINKER WITH THE BACKEND OF CODE YOU DO NOT UNDERSTAND.

So once you’ve downloaded a custom functions.php plugin that allows you to add code, you will want to hide everything that is irrelevant when printing, and this will cut out about 3 or 4 pages and modify the backend page to be more print-friendly with focus solely on the Event Title and the table contents.

My client has more custom requests where she asks questions upon registration and I’ve hijacked the page to show the answers to those questions in the table to help her understand her customers better (specifically replacing the email and tkt option section with a phone nuumber and a seating notes section), so it is more than just the name she needs from this page, so this may not be a use-case for everyone.

But for anyone who might need the code for printing a backend page in the WordPress admin:

add_action('admin_head', 'event_check_in_print_css_admin');

function event_check_in_print_css_admin() {
  echo '<style>@media print {
    .admin-sidebar, #wpadminbar, .check-column, span.dashicons.dashicons-no.checkin-icons.checkedin-status-2, input[type="checkbox"], .espresso-admin .wp-list-table.widefat th.check-column input[type="checkbox"], .espresso-admin .wp-list-table.widefat td.check-column input[type="checkbox"], .espresso-admin .wp-list-table.widefat th.check-column .dashicons-lock, .espresso-admin .wp-list-table.widefat td.check-column .dashicons-lock, .espresso-admin .wp-list-table.widefat th.check-column input[type="checkbox"], .espresso-admin .wp-list-table.widefat td.check-column input[type="checkbox"], .espresso-admin input[type="radio"], .espresso-admin input[type="checkbox"], .folded #adminmenu, .folded #adminmenu li.menu-top, .folded #adminmenuback, .folded #adminmenuwrap, .search-box, #bulk-action-selector-, .alignleft actions bulkactions, .button action, #add-new-registration, .espresso-admin.wp-core-ui .wrap .nav-tab-wrapper, #screen-meta-links, .check-column, .espresso-admin .tablenav .ee-event-filter > span label, .ee-help-btn, .espresso-admin .tablenav input+label, .espresso-admin .tablenav input+.button, .espresso-admin .tablenav #post-query-submit, .espresso-admin.wp-core-ui .ee-list-table-actions a .dashicons, .espresso-admin.wp-core-ui .button.button--icon-only .dashicons, .espresso-admin.wp-core-ui .button.button--icon-only .dashicons:before, .espresso-admin.wp-core-ui #search-submit, .espresso-admin.wp-core-ui .tablenav #doaction, .espresso-admin.wp-core-ui .tablenav #doaction2, .espresso-admin.wp-core-ui .tablenav .button.button--secondary, .ee-list-table-legend-container, .csv-report-notice__wrapper, .espresso-admin.wp-core-ui .button-primary:not([disabled]), .espresso-admin.wp-core-ui .button.button-primary:not([disabled]), .espresso-admin.wp-core-ui .button.button--primary:not([disabled]), .wp-core-ui .espresso-notices .button.button--primary:not([disabled]), .espresso-admin.wp-core-ui .publishing-action input[type="submit"]:not([disabled]), .espresso-admin.wp-core-ui input[type="submit"].button.button-primary:not([disabled]), .espresso-admin.wp-core-ui input[type="submit"].button.button--primary:not([disabled]), .espresso-admin.wp-core-ui .mce-toolbar .mce-btn-group .mce-btn.mce-active button:not([disabled]), .espresso-admin.wp-core-ui .html-active .wp-editor-tabs button.wp-switch-editor.switch-html:not([disabled]), .espresso-admin.wp-core-ui .tmce-active .wp-editor-tabs button.wp-switch-editor.switch-tmce:not([disabled]), .espresso-admin.wp-core-ui .mce-toolbar .mce-btn-group .mce-btn:active, .qt-dfw.active button:not([disabled]), .manage-column column-cb check-column, row.check-column, #wpfooter p, #wpfooter, h1, .subsubsub, .tablenav-pages, .ee-event-filter, .ee-event-filter-main-label { display: none!important; }
@page { page-break-after: always!important; }
body {
/* adjust margins to the left to account for the checklist items we removed */
margin: 0!important;
left: 0%!important;
margin-left: -10%!important;
width: 100%!important; 
max-width: 100%!important;
}
}
</style>';
}


kellyjo

July 21, 2023 at 11:22 am

And a last comment on a comment:

// Check if count is equal to group_size and skip the row if they are equal

This is supposed to say:

// Check if count is equal to group_size and skip the row if they are NOT equal

We only care about the TOTAL NUMBER of tickets/seats purchased matching the current count and will display the row IF THEY MATCH.

Viewing 7 reply threads

The support post ‘Condensed Seating Code’ 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