Posted: November 12, 2021 at 8:40 am
|
I have configured tickets for sale where a client can purchase a max of 1 ticket. For such cases, would it be possible to change the current dropdown menu with values of 0 and 1 with a simple checkbox for the client to select. Ex: https://lavana.org/events/2022-q1-veggie-shares-test/ Also for such cases, I would like to have an additional overall checkbox which can select all the ticket items for the event. In the above example, there are 6 tickets and it would really be nice if the user can select/buy one of each ticket with a single click (or have an option to select specific tickets only). Hope my request is clear. Let me know if there is some way to achieve this. Thanks, |
Hi Hemang,
It’s important to note that your setup means the client can purchase a max of 1 from each ticket type. Its not a max of 1 ticket (we have an option for that) but 1 of each type.
We currently don’t have an option for this within Event Espresso itself, although if you are comfortable with JavaScript you could add this in via a hook. Here is an example: https://gist.github.com/Pebblo/737310c7309436231008666ac27e9662 However, note that you will also need to add some form of check within that function to only added it to the events you want to use it on, for example, a custom field within the event which if set adds the above code on the single event output.
This is similar to above in that we don’t have an option for it although you could extend the example I gave you above to to add this in. |
|
|
Nice, this seems to be working well. I have some issue with the 2nd part of my question – the “Select All” option. I have been able to setup such checkbox and also when I click on it, it checks or unchecks the rest of the checkboxes. However, when I try to proceed with the “Registration”, it always complains with an error that no tickets have been selected. You may try it out yourself here: https://lavana.org/events/2022-q1-veggie-shares-test/ Any idea what could I be doing wrong? A related question. I wanted to replace the text in table header called “Qty” with the “Select All” checkbox. How can I do that? |
How are you adding the select all option? Where are you adding the JavaScript to handle the click event?
You can use the Like so: https://gist.github.com/Pebblo/6c8c3c8d84b9d77608d9116bfe012dec |
|
|
Great – Qty replacement hook worked like a charm. I have changed Qty with:
For the select all option, I have created a javascript function:
Can you suggest how to improve this function. |
Why not just use some jQuery to make this really simple:
Whenever the select all checkbox is clicked call change on all of them, which then gets managed by the other snippet I gave you for each individual checkbox. |
|
|
Can you provide bit more details on how can I use your jQuery. I am a newbie to this, so it would be great if you can provide details on where exactly should I place the jquery code. |
Just to note, when anyone starts posting code I’m going to automatically assume they know how to use it unless it’s stated otherwise 🙂 Where you currently have this code: https://gist.github.com/Pebblo/737310c7309436231008666ac27e9662 Change it to be this one: https://gist.github.com/Pebblo/aadb2c7349b5093d807974aabf60288b That should do it for you. |
|
|
Still doesn’t work. I must be missing something very simple. I have this: https://gist.github.com/Pebblo/aadb2c7349b5093d807974aabf60288b and this:
The “Qty” table header gets replaced with a checkbox and “Select All”, but when I click on the select all checkbox, it does not seem to select the checkboxes of various tickets. You may check out the behavior over here: |
|
After some debugging, I finally figured out the issue. Here’s the updated code snippet that worked for me:
There were couple of issues: (1) the checkbox selection for each individual entry was working, but unselecting it would not update the value back to 0. So I had to add the “else” clause, and (2) the jquery for “Select All” would call the change function for all checkboxes, but first its value had to be updated to match the “select all” value. Thanks for all your help. This is now mostly working very well (few minor issues, like browsing back leaves the “Select All” value in different state, or the “Register” button should be greyed out until at least 1 ticket is selected. |
My apologies, I’d signed off before your reply so didn’t see the above until now. Nice work, I’m glad its working for you 🙂 |
|
The support post ‘Use checkbox for ticket selector when max tickets allows to purchase is 1’ 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.