Events Made Easy › Forums › How do I … › Problems with Discount / funktions.php
- This topic has 2 replies, 2 voices, and was last updated 7 years, 2 months ago by Anonymous.
-
AuthorPosts
-
Fri 29 Sep 2017 at 16:00 #56698AnonymousInactive
Hello,
i want to integrate Discounts in my events. So i created any discounts.
The type of this discounts is 4 (Endprice for the event). CouponCode is a number…Then i created a Formular-Field Named “RABATTCODE”
This i insert in my bokking-side:
<th scope=”row”>GutscheinCode: </th>
<td>#RABATTCODE</td>then i changes the funktions.php
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’];//if ($event_id == 5) { /* put in the event_id that needs processing, or leave out this line to process all events */
//echo ‘EVENT ID=’.$event_id .’ Booking_id = ‘.$booking[‘booking_id’];$seats=$booking[‘booking_seats’];
// more than 2 seats, then the discount is 5 per seat
if ($seats>= 1)// below a small example to check own input
$coupon = “”;
$answers = eme_get_answers($booking_id);
foreach ($answers as $answer) {
if ($answer[‘field_name’] == “RABATTCODE”) {
$coupon = $answer[‘answer’];
}
}
// now check $coupon for your wanted value$fields[‘discount’] = $discount;
$where[‘booking_id’] = $booking[‘booking_id’];
$wpdb->update($bookings_table, $fields, $where);
//}
return;
}When Persons booking a event the seats always be one Seat, so i don´t need multibooking-seats at once.
Now when i make a booking nothing changes the price of the event…can anyone help me with this problem? because i want to use this funktion. Later i want to reduce the price with the coupon-code (ex. 100€ -10€).. All the informations are in the Discount-table, so i think the code in the functions.php should be integraded all this functions….
thank you for helping
Fri 29 Sep 2017 at 16:52 #56699FrankyKeymasterHi, read this page concerning discounts:
http://www.e-dynamics.be/wordpress/category/documentation/17-discounts/For type=4 (= fixed discount per seat), there is no need to change anything in your functions.php.
Just read the last paragraph:
Now that we have discounts, indicate in the event (in the rsvp section) the name of the discount or discount group you want to apply.
After that, change the format of the RSVP form and add one or more discount form fields using the placeholder #_DISCOUNT (can be used multiple times). This placeholder should NOT be used if the discounttype is ‘code’ (since that ignores the entered value anyway).
Fri 29 Sep 2017 at 17:45 #56700AnonymousInactiveYeah.. Thanks.. this works 😉
I forget the bolded text 😉 -
AuthorPosts
- The forum ‘How do I …’ is closed to new topics and replies.