Hi
Is it possible to apply a discount to a ticket via a dropdown in the booking form ?
The event is a netball clinic and there are 10 spaces each at offense, mid and defense, but I would also like to set up a sibling discount, ie $10 discount for first sibling, $20 for second etc. Also is it possible to change the ticket selection table to a dropdown as only one ticket is purchased per registration form.
The way I would like it to work is that they select the playing position via a dropdown and then they select a sibling discount via another dropdown before being directed to Paypal for payment.
Regards
Daniel
Daniel Cooksey
Hi Daniel,
It’s not possible to change the ticket selection to a dropdown, but you can change them to radio buttons. You’ll need to edit the ticket template, and using the following: https://wp-event-organiser.com/forums/topic/limit-one-ticket-per-person/#post-10052
As for the applying a discount based on a dropdown value this is possible. I’d recommend you add the field via the API rather than the UI customiser – simply because it gives you a concrete (HTML) ID to work with. It’s less fragile then using the auto-assigned IDs the form customiser gives you, which will change if you remove and re-add the element.
As for discount logic, you’ll need to this mostly yourself, but I have just published an un-tested ‘skeleton’ plugin: https://gist.github.com/stephenharris/6b80f310a107e8aca9ce93508e5b5934
There are two places where you’ll need edit it to handle your discount.
Firstly, on the frontend – you’ll need to determine the value currently selected in the field and assign a float value to the discount
accordingly.
Since that only deals with displaying the discount on the front-end, you’ll need to effectively replicate that logic in PHP here: https://gist.github.com/stephenharris/6b80f310a107e8aca9ce93508e5b5934#file-bulk-discount-php-L109. You can get the value that was selected from the dropdown via:
$selected_value = eo_get_booking_meta( $booking_id, 'meta_{element ID}' );
Similarly to before, you’ll need to use that value to decide what $discount_amount
should be.
I hope that helps but please note that the plug-in I linked to hasn’t been tested yet.
Stephen Harris
I have been trying to get this working but it is over my head.
When I install your discount script as a plugin I get – “call_user_func_array() expects parameter 1 to be a valid callback, class ‘EO_Discount_Codes’ not found in…”
and when I submit the form I get – “Cannot modify header information – headers already sent by…”, and nothing gets changed.
I also tried adding the functions using a custom functions plugin, using this method i don’t get the above warnings but still no discounts are applied. even when $discount_amount is set to a fixed amount. I suspect it’s a javascript issue but don’t know how to prove it.
Sorry if this is a bit brief but I’ve just spent a couple of hours trying to work this out I’m just going around in circles.
Daniel Cooksey
Hi Daniel,
Did you activate the Discount Codes plugin as well as the snippet I linked to (that would need to be jnstalled and activated too).
Stephen Harris