Support

Home Forums Event Espresso Premium Select Tickets in Multiples of 2

Select Tickets in Multiples of 2

Posted: August 23, 2017 at 10:09 am

Viewing 10 reply threads


scarenews

August 23, 2017 at 10:09 am

I have a ticket called Member + Guest, which is for two people. I have it set up as a ticket bundle (min 2, max 2), but I want the user to be able to select multiples of 2. For example, 2, 4, 6, etc.

I found an old post with a dead link to some JQuery, so I am hoping there’s an updated way to do this. Thanks!


scarenews

August 23, 2017 at 10:14 am

The old support post was this one: https://eventespresso.com/topic/sell-tickets-in-multiples-of-2-etc/


Josh

  • Support Staff

August 23, 2017 at 3:08 pm

Hi there,

In order to allow more than 2, you’ll need to change the ticket’s maximum limit from 2 to something like 10, 16, or 20.

Then you can add some code to your site like the following to remove the odd numbered option values:

add_action( 'wp_enqueue_scripts', 'my_ee_remove_odd_quantity_options', 11 );
function my_ee_remove_odd_quantity_options() {
  wp_add_inline_script( 
    'ticket_selector',
    'jQuery( document ).ready(function($) {
      $(".ticket-selector-tbl-qty-slct option:even").remove();
    } );'
  );
}

You can add the above to a functions plugin or into your WordPress theme’s functions.php file.


scarenews

August 25, 2017 at 1:19 pm

Thanks. This worked; however, I have 3 ticket types:

Member ONLY
Guest ONLY
Member + Guest

Member+Guest is the one that needs to be in pairs, which is just what your code did. However, now Member ONLY and Guest ONLY show up 1,3,5,7,9 and 2,4,6,8 respectively. Any ideas?


Josh

  • Support Staff

August 25, 2017 at 2:21 pm

You’ll need to change the selector in the code,
.ticket-selector-tbl-qty-slct, to be more specific so it only changes the one option. If you can post a link to the page in question I can take a look and point out what you’d actually change the selector to.


scarenews

August 27, 2017 at 8:42 pm

The page is behind a members-only site. How can I send you log-in details? Or, I could post the code snippet from the form if that would help.


Tony

  • Support Staff

August 28, 2017 at 4:20 am

EE adds a class to the table row for each ticket that uses the ticket name – http://take.ms/wSLxz

The format of that class is ee-ticket-{ticket-name}, and spaces will be converted to dashes and all characters are lower case. So a ticket called ‘My Event Ticket’ becomes ‘ee-ticket-my-event-ticket’.

You can use that in the above code to be more specific:

$(".ee-ticket-my-event-ticket .ticket-selector-tbl-qty-slct option:even").remove();

If that doesn’t help, you can send login details using:

https://eventespresso.com/send-login-details/


scarenews

August 28, 2017 at 9:18 am

That worked wonderfully with one exception. It now lists “2” as the default number instead of 0. Can this be changed?


Josh

  • Support Staff

August 28, 2017 at 9:31 am

Of course. You’ll go into the event editor, then click on the gear icon to open the advanced ticked editor for the Member + Guest ticket, and change the Minimum Quantity field to 0 or leave it blank. Then you update the event to save the change.


scarenews

August 28, 2017 at 9:49 am

Ok, I got it. I updated the minimum to 0, but it then showed 1,3,5,7. So, to resolve this I changed the code to:

add_action( 'wp_enqueue_scripts', 'my_ee_remove_odd_quantity_options', 11 );
function my_ee_remove_odd_quantity_options() {
  wp_add_inline_script( 
    'ticket_selector',
    'jQuery( document ).ready(function($) {
      $(".ee-ticket-member-guest .ticket-selector-tbl-qty-slct option:odd").remove();
    } );'
  );
}

Instead of removing the EVEN’s, I had to remove the ODD’s. Counterintuitive, but worked.


Josh

  • Support Staff

August 28, 2017 at 9:55 am

You’ll note why it’s counterintuitive (it’s 0-based indexed) in jQuery’s documentation for the :odd selector:

https://api.jquery.com/odd-selector/

Viewing 10 reply threads

The support post ‘Select Tickets in Multiples of 2’ 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