Disable Add to Cart button whilst ticket quanitity field equals 0

Home Forums Ticket Products Event Tickets Plus Disable Add to Cart button whilst ticket quanitity field equals 0

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1144510
    Dean
    Participant

    Hi,

    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.

    #1144929
    Josh
    Participant

    Hey 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!

    #1145017
    Dean
    Participant

    Hi 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'});
    		}
    	});
    });
    #1145058
    Josh
    Participant

    Hey 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!

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘Disable Add to Cart button whilst ticket quanitity field equals 0’ is closed to new replies.