Home › Forums › Ticket Products › Event Tickets Plus › Selling multiple tickets in groups of 2.
- This topic has 7 replies, 3 voices, and was last updated 10 years, 2 months ago by
Support Droid.
-
AuthorPosts
-
January 29, 2016 at 6:30 am #1064458
Emiliano Pasini
ParticipantHi, I would like to know if there is a way of applying a rule to all the events/tickets to sell tickets in groups of 2.
To be more precise, I need to sell in multiples of 2 ( 2, 4 , 6 , 8, 10, etc ). There is a plugin that make the rule for each product but I would like to do the same appliying the same rule to the hole calendar if possible.
Many thanks,
EmilianoJanuary 29, 2016 at 7:05 am #1064467George
ParticipantHey Emiliano,
Thanks for reaching out!
Just to be clear, do you mean that your goal is literally so that a person can never by just one, three, or five tickets for example? But only tickets in multiples of two?
If so, this is not possible with the plugins at this time. It would require an extensive bit of custom coding. We unfortunately cannot help with custom coding, but let me know if you can confirm that my above summary of your goals is accurate.
If so, I will try to tinker around with the code a bit and see if I can recommend a solution or some ideas at least.
Thank you!
GeorgeJanuary 29, 2016 at 7:17 am #1064477Emiliano Pasini
ParticipantHi George, thanks for your answer. Yes that’s exactly what I’m trying to achieve, it would be much appreciated a solution for this!
Many thanks,
EmilianoJanuary 30, 2016 at 8:10 am #1065038George
ParticipantHey Emiliano,
Thanks for your patience with this while I investigated and wrote some code. It’s actually a rather simple change to make to get the quantity field for tickets to only work in multiples of two–you can simply add code like the following to your theme’s functions.php file:
add_filter( 'woocommerce_quantity_input_step', 'tribe_woo_make_step_2' );function tribe_woo_make_step_2() {
return 2;
}
Now, in some cases users could manually alter the value to be something like 3 or 5 anyways…making it truly impossible to enter a non-multiple of 2 value is a bit tricky, but with even a little bit of JavaScript you can make it very, very hard to submit a purchase with a value of tickets that is not a multiple of 2.
I unfortunately cannot help implement a better solution than what I have here, but what I have here is another bit of code you can add to your theme’s functions.php file – this extra bit of JavaScript will throw an error if users try to buy 0 tickets, or some a value that is not divisible by 2:
add_action( 'wp_footer', 'tribe_woo_check_if_quantity_is_multiple_of_2' );function tribe_woo_check_if_quantity_is_multiple_of_2() {
wp_enqueue_script( 'jquery' ); ?>
<script>
jQuery(document).ready(function($){
if ( $( 'td.woocommerce.add-to-cart' ).length ) {
$( 'td.woocommerce.add-to-cart' ).on( 'click', 'button', function(e) {
var $table = $( e.delegateTarget ).parents( '.tribe-events-tickets' );
var qty = $table.find( 'input.input-text.qty.text' ).val();if ( ( qty > 1 ) && ( qty % 2 == 0 ) ) {
// Good to go!
} else {
e.preventDefault();
alert( 'You can only buy tickets in multiples of 2.' );
}});
}
});
</script><?php
}
I hope this all helps!
Cheers,
GeorgeFebruary 11, 2016 at 6:47 am #1071505Emiliano Pasini
ParticipantHi George, this is great, thanks so much for your help!
Just one more thing if possible, we need to limit the amount of tickets that someone can buy ( 12 tickets max )
There is a way on the system for choosing the max amount of tickets that the user could buy?Thanks!
February 11, 2016 at 6:49 am #1071506Emiliano Pasini
ParticipantI mean, the maximun tickets that someone could buy on each transaction should be 12.
February 11, 2016 at 5:55 pm #1071782George
ParticipantHey @emiliano,
Setting the limit that way is unfortunately not possible without even more code customizations 🙁 Doing that is a bit more complicated than the custom code I was able to write for the other aspect of this, and so unfortunately you would either have to write that custom code yourself or hire a developer to write that code for you.
I’m sorry about this, @emiliano!
Please let me know if there’s anything else I can help with.
Sincerely,
GeorgeFebruary 26, 2016 at 8:35 am #1082468Support Droid
KeymasterThis topic has not been active for quite some time and will now be closed.
If you still need assistance please simply open a new topic (linking to this one if necessary)
and one of the team will be only too happy to help. -
AuthorPosts
- The topic ‘Selling multiple tickets in groups of 2.’ is closed to new replies.
