- This topic has 3 replies, 2 voices, and was last updated 6 years, 11 months ago by .
Viewing 4 posts - 1 through 4 (of 4 total)
Viewing 4 posts - 1 through 4 (of 4 total)
- The forum ‘How do I …’ is closed to new topics and replies.
Events Made Easy › Forums › How do I … › set a discound for a category or a reacurring event
Tagged: category based discount, discound, php
Following the instructions of your documentation i created a function in my functions.php file.
The thing i am trying to figure out is how do i tell it to run the discount on every event of a certain category or on every event of a reacurring catergory. In my case, it doesn’t make a difference, both describe the same thing.
Basically, based on the event id that i get through the $booking, how do i get the category inside my php code.
Thanks for the support,
Sangpur
if the standard discount types are sufficient, I’d suggest that you change the recurrent event itself, then all the events in that recurrence will get the discount options.
See the RSVP section for that.
This is not possible for a category of course …
My discount is a bit more special and can only be realized this way:
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();
$booking_id = $booking[‘booking_id’];
$event_id = $booking[‘event_id’];
//HERE i need to check for category_id instead of event_id
if ($event_id == 4) {
//echo ‘EVENT ID=’.$event_id .’ Booking_id = ‘.$booking[‘booking_id’];
$seats=$booking[‘booking_seats’];
$price=$booking[‘booking_price’];
// standart price = 1500 per person
// 3 or more price = 1350 p.p.
// 6 or more price = 1200 p.p.
if ($seats> 2)
$price = 1350;
if ($seats> 5)
$price = 1200;
$fields[‘booking_price’] = $price;
$where[‘booking_id’] = $booking[‘booking_id’];
$wpdb->update($bookings_table, $fields, $where);
}
return;
}
I need to know how you get the category id if you have the event id.
I was hoping someting along these lines can be done:
$category_id = $event[event_id]->$category;
you can get the full event as follows:
$event = eme_get_event($event_id);
Then do a print_r of the $event variable: you’ll see the category-id’s (if multiple: comma-separated) and also the recurrence id.