Discounts

Discounts need some special care: you need to define one or more discount fields in the RSVP form, upload discount and discountgroup CSV-files (if you want to mass-import discount definitions) and indicate which discount or discountgroup you want to use for your event.

First, let’s start how to define discounts or discountgroups. Then (at the bottom), find the 5-seconds method of how to use your defined discouts (or groups) in your events.

Discountgroups

Discountgroups allow to group several discounts together (so several discounts can be applied to a booking).
When defining a discountgroup, fill out the fields based on the info below (those marked with ‘*’ are mandatory fields):
name*: the name of the group
description: a description. The default is empty.
max discounts: max number of discounts belonging to that group that can be applied per booking (you can have 255 discounts belonging to the same group, but you can for example decide that people can only enter 2 discount codes). The default is 0, meaning no limit. If this number is greater than zero, the below mentioned #_DISCOUNT placeholder should be used the same amount of times as this number.

Discounts

Discount types

There are several discount types:
fixed: the discount is a fixed price that will be deducted from the total price
percentage: the discount is a percentage from the total price to pay
code: the discount is done using own php coding, leaving you free to check other databases for info, add extra conditions, etc. See be
fixed per seat: the discount is a fixed price that will first be multiplied by the number of booked seats and then deducted from the total price.

Discount definition

Discounts can indicate the type (fixed, percentage, …), the coupon code people must enter, how many time this coupon code can be used, the group the discount belongs to and an expiration time
When defining a discount, fill out the fields based on the info below (those marked with ‘*’ are mandatory fields):
name*: the name of the discount
description: a description. The default is empty.
type*: 1 (fixed discount), 2 (percentage based discount), 3 (discount based on code), 4 (fixed discount applied per seat).
For the code-type (type 3), you need to create a filter based on the discountname, see below for an example
coupon*: the coupon code people must enter
discount group: the name of the discount group this discount belongs too (default: empty)
value*: the discount to apply (example: ‘1’ will give you a discount of 1 dollar in case of type fixed, or 1 percent in case of type percentage)
max usage: the maximum amount of times this discount can be used. The default is 0, meaning no limit.
expire: expiration date (when importing discounts via csv, the format needs to be YYYY-MM-DD). Default: none.
case sensitive: indicate if your coupon code should be case sensitive or not. Default: 1 (case sensitive). The other value is “0” (case insensitive)

Discount filters (code type discount)

For the discount type “code”, create a filter based on the discount name, for example eme_discount_testdiscount2 (“eme_discount_” is fixed, the “testdiscount2” part comes from the name given to the discount) in your theme’s functions.php (I suggest to create a child theme) that takes the booking as parameter. Example (change the function please):

function my_eme_discount_function($booking) {
    //print_r($booking);
    $answers=eme_get_booking_post_answers($booking);
    //print_r($answers);
    // now calculate your stuff based on the booking and answers arrays
    // and return the discount. A starting example:
        //foreach ($answers as $answer) {
        //    if ($answer['field_name'] == "MY_FIELD_NAME") {
        //       $coupon = $answer['answer'];
        //    }
        //}
        // now check $coupon for your wanted value and do the discount ($booking has all the booking info)
    return $calculated_discount;
}
add_filter('eme_discount_testdiscount2','my_eme_discount_function');

A working example where you give 30% discount if a certain field called MY_FIELD_NAME has the value “yes:

function my_eme_discount_function($booking) {
    $calculated_discount=0;
    $coupon="";
    // calculate your stuff based on the booking and answers arrays
    // and return the discount. A starting example:
    $answers=eme_get_booking_post_answers($booking);
    foreach ($answers as $answer) {
        if ($answer['field_name'] == "MY_FIELD_NAME") {
               $coupon = $answer['answer'];
        }
    }
    // now check $coupon for your wanted value and do the discount ($booking has all the booking info)
    if ($coupon == "yes") {
            // return a total discount of 30%
            $calculated_discount=$booking['event_price']*$booking['booking_seats']*.3;
    }
    return $calculated_discount;
}
add_filter('eme_discount_testdiscount2','my_eme_discount_function');

Discounts in events

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).

Scroll to Top