Discount for multiple tickets
-
I need to be able to create an event where there are a max of say 6 tickets in total. I then want to offer single ticket prices of say £30 or if 2 tickets are bought the price is £50. I only have 6 tickets regardless or whether I sell 6 x 1 tickets or 3 x 2 tickets.
I’ve looked through the documentation and questions and can’t see this answered anywhere. Is this possible and if so how please?
-
For the moment you need to program discounts in yourself via the filter eme_insert_rsvp_action, see https://www.e-dynamics.be/wordpress/?cat=41
Thanks Framky.
I’ve had a look at that link and I’m afraid it doesn’t make that much sense to me ?? I’m not really a developer. J
Then I’m sorry, but for now discounts are not implemented directly into EME. Something on my todo list …
No worries…if you can drop me a step by step instruction, I would gladly make a donation to the project.
Franky, I wrote you on your e-dynamics support page about this same thing.
I’ll also make a donation for step-by-step instructions to do this.
Please.
Sorry for the late reply, and yes, I did see your post at the forum.
But if you’re unfamiliar with php, it’s not that simple.
I’ll see if I can cook up an example later on …Here’s a post of somebody using the eme_update_rsvp_action filter:
https://www.e-dynamics.be/bbpress/topic.php?id=2106#post-8777It’s similar to what you want, but instead you’d want to update the price field. So put the following in your theme functions.php (for a single-price-category event):
add_action('eme_insert_rsvp_action', 'my_eme_discount_function',20,1); function my_eme_discount_function($booking) { global $wpdb; $bookings_table = $wpdb->prefix.BOOKINGS_TBNAME; $where = array(); $fields = array(); $event_id = $booking['event_id']; if ($event_id == 9467) { /* put in the event_id that needs processing */ //echo 'EVENT ID='.$event_id .' Booking_id = '.$booking['booking_id']; $seats=$booking['booking_seats']; $price=$booking['booking_price']; // more than 2 seats, then the price is 25 per seat if ($seats> 2) $price = $seats * 25; $fields['booking_price'] = $price; $where['booking_id'] = $booking['booking_id']; $wpdb->update($bookings_table, $fields, $where); } return; }
Thanks for this Franky. I have either misunderstood or done something wrong as I added the code under the line below to the functions.php file (Which is the above with simply the event ID changed to match the ID that I wanted the ‘multibuy’ price for.) When I did this the price was reduced to zero. I suspect that I’m very close to being there but can’t work out what else I need to do!?
****************************************************************************************
add_action(’eme_update_rsvp_action’, ‘count_only_attendance_tickets_on_update’,20,1);
function count_only_attendance_tickets_on_update($booking) {
global $wpdb;
$bookings_table = $wpdb->prefix.BOOKINGS_TBNAME;
$where = array();
$fields = array();$event_id = $booking[‘event_id’];
if ($event_id == 5) { /* put in the event_id that needs processing */
//echo ‘EVENT ID=’.$event_id .’ Booking_id = ‘.$booking[‘booking_id’];$seats=preg_split(“/\|\|/”,$booking[‘booking_seats_mp’]);
/* use only attendance tickets,#_SEATS1 and #_SEATS2, array values 0 and 1 */
$tix_tot = $seats[0] + $seats[1];$fields[‘booking_seats’] = $tix_tot;
// echo ‘Attendence tix_tot =’ . $tix_tot;
$where[‘booking_id’] = $booking[‘booking_id’];
$wpdb->update($bookings_table, $fields, $where);
}
return;
}you’re not using the example I gave, start with that. The example you used is for multiseats events.
Oops I cut and pasted the info from the wrong page into this thread…I did use the correct text…. below is what I have used on my website with the previously mentioned results.
add_action('eme_insert_rsvp_action', 'my_eme_discount_function',20,1); function my_eme_discount_function($booking) { global $wpdb; $bookings_table = $wpdb->prefix.BOOKINGS_TBNAME; $where = array(); $fields = array(); $event_id = $booking['event_id']; if ($event_id == 5) { /* put in the event_id that needs processing */ //echo 'EVENT ID='.$event_id .' Booking_id = '.$booking['booking_id']; $seats=$booking['booking_seats']; $price=$booking['booking_price']; // more than 2 seats, then the price is 25 per seat if ($seats> 2) $price = $seats * 25; $fields['booking_price'] = $price; $where['booking_id'] = $booking['booking_id']; $wpdb->update($bookings_table, $fields, $where); } return; }
[Moderator Note: Please post code & markup between backticks or use the code button. Your posted code may now have been permanently damaged by the forum’s parser.]
Well … at a first glance it seems ok to me.
What you can always do is do a print of the price variable there and “die” then, so you’ll see what the price value is.
I’ll test this out this evening.OK. I think I’ve gone some way to fix it now…I’ve amended the logic slightly as the price is reduced if the client is buying >1 ticket.
However it appears that the multiplication is now being done twice…as the amount being asked for is £100 for 2 tickets (£25 x2 x2) and £225 for 3 (£25 x3 x3).
Have I done something wrong here?
Ok, I’ve got it working now for one event using the below… Thanks Franky.
How do I duplicate this for several events?
*************************************************************************
[ Moderator note: please wrap code in backticks or use the code button. ]
add_action('eme_insert_rsvp_action', 'my_eme_discount_function',20,1); function my_eme_discount_function($booking) { global $wpdb; $bookings_table = $wpdb->prefix.BOOKINGS_TBNAME; $where = array(); $fields = array(); $event_id = $booking['event_id']; if ($event_id == 5) { /* put in the event_id that needs processing */ //echo 'EVENT ID='.$event_id .' Booking_id = '.$booking['booking_id']; $seats=$booking['booking_seats']; $price=$booking['booking_price']; // more than 2 seats, then the price is 25 per seat if ($seats> 1) $price = 25; $fields['booking_price'] = $price; $where['booking_id'] = $booking['booking_id']; $wpdb->update($bookings_table, $fields, $where); } return; }
What did you change?
For more than one event, eg. for event id’s 5,7,11:if ($event_id == 5 || $event_id==7 || $event_id==11)
Thanks will try the multiple events…
I changed:
[ Moderator note: please wrap code in backticks or use the code button. Really, the code button is your friend. ]
if ($seats> 2) $price = $seats * 25;
to:
if ($seats> 1) $price = 25;
- The topic ‘Discount for multiple tickets’ is closed to new replies.