Home › Forums › Ticket Products › Event Tickets Plus › Disable Add to Cart button whilst ticket quanitity field equals 0
- This topic has 4 replies, 3 voices, and was last updated 10 years ago by
Josh.
-
AuthorPosts
-
July 27, 2016 at 1:02 am #1144510
Dean
ParticipantHi,
Some of my clients’ users have mentioned a usability issue (for them) when attempting to purchase a ticket.
When on an events page a user can click the “Add to Cart” button whilst the purchased ticket quantity is 0, taking them onto an empty cart page. They then have to return to the events page and work out what they did wrong.
I’ve spent some time searching for code or plugin solutions to try and find a way to disable the cart button (greying it out maybe?) until the quantity field is greater than 0, but no joy.
Is there any code available or have you come across a solution to this?
Thank you.
July 27, 2016 at 5:21 pm #1144929Josh
ParticipantHey Dean,
Thanks for reaching out to us!
We have run across this particular issue, however the most common solution that we suggest would be to make the default value for the field to be “1”.
You can accomplish this by following our Themer’s Guide and copying the ticket form (src > views > wootickets > ticket-form.php) into your theme and making the default input value there to “1” (line 60 in the current version).
Let me know if this helps.
Thanks!
July 28, 2016 at 12:46 am #1145017Dean
ParticipantHi Josh,
Thank you for the quick response. Yes, that worked a treat. I combined it with the below code I wrote (sorry but I’m not a JS developer – but it works!) so if the quantity count was set or reduced to zero the Add to Cart button disappeared.
jQuery(document).ready(function($) { var eventQty = $('.tribe-events-single input.qty').val(); if (eventQty == 0) { $('.add-to-cart button').css({'display':'none'}); } $( '.tribe-events-single input.qty' ).change(function() { var eventQty = $('.tribe-events-single input.qty').val(); if (eventQty == 0) { $('.add-to-cart button').css({'display':'none'}); } else if (eventQty > 0) { $('.add-to-cart button').css({'display':'block'}); } }); });July 28, 2016 at 5:45 am #1145058Josh
ParticipantHey Dean,
Awesome! I’m glad you were able to use that information and get something like this working.
Also, thanks for that snippet! I’m sure others will find that very helpful when searching in the future.
I’ll go ahead and close this thread for now. If you have any further questions, please don’t hesitate to open a new one.
Thanks!
-
AuthorPosts
- The topic ‘Disable Add to Cart button whilst ticket quanitity field equals 0’ is closed to new replies.
