Home Forums Event Espresso Premium Discount by Tickets

Discount by Tickets

Posted: October 9, 2019 at 8:17 am

October 9, 2019 at 8:17 am

I see this feature was discussed in 2015 and 2016.

It seemed like over 80 of your users voted in favor of having discount codes being applied to certain ticket types. Any update on this feature?

It is really something I need to continue my subscription. What would it cost to sponsor the development of this feature as Seth suggested?


  • Support Staff

October 9, 2019 at 8:49 am


One update that did happen since then is the promotions add-on now includes hooks that allow for programmatically setting a specific ticket to allow a specific promotion. An example of how to use the hooks is hosted here:

With the above, a PHP developer could build out a system of discounts per ticket to your specifications.

If you’d prefer to look into sponsorship of a ticket per promotion user interface, to be included in an official update to the promotions add-on, you can reach out to Seth via this form:

October 9, 2019 at 9:55 pm

I have tested out the code and it does indeed limit promo codes to specific tickets. However it ignores the use limit, which I still need

The filter “FHEE__EED_Promotions__add_promotion_line_item__bypass_increment_promotion_scope_uses” appears to be responsible for bypassing the use limit. I’ve tried setting the return value to false as well as commenting out the entire add_filter() line in hopes of enforcing the use limit. No luck.

Do you know if there’s a fix for this?


  • Support Staff

October 11, 2019 at 2:28 pm

The filter is supposed to bypass the use limit, because what’s happened is the event scope is no longer in effect. There isn’t a check for “ticket scope usage limit”. Usage limits are applied to and checked against for the event scope.

What you could do in this case is add some additional logic and a loop at the very end of the main loop that gets the event ID from the tickets, then applies the usage for the promotions to the event scope. At that point it will work because the plugin still checks for the event scope’s usage limit.

e.g. add the following just before the end of the main foreach loop

// get ticket object
$ticket = EEM_Ticket::instance()->get_one_by_ID($ticket_line_item->OBJ_ID());
if ($ticket instanceof EE_Ticket) {
    // get related event object
    $event = $ticket->get_related_event();
    if ($event instanceof EE_Event) {
        foreach (range(1, $applicable_items[0]->get('LIN_quantity')) as $i) {
            // increment usage to event scope
            try {
                if ($promotion->scope_obj()->increment_promotion_scope_uses(
                )) {
            } catch (Exception $e) {
                EE_Error::add_error($e->getMessage(), __FILE__, __FUNCTION__, __LINE__);

October 14, 2019 at 10:45 am

This is great. Only issue I found is that the use limit isn’t applied until after a transaction pushes the usage count to equal or greater than the use limit.

For example, let’s say promo code XYZ has a use limit of 4. The newly added foreach loop will allow me to apply the code to 5 tickets. After I complete the transaction, the promo code is no longer valid and prompts as such.

Is it possible to make the use limit apply for this use case?


  • Support Staff

October 15, 2019 at 3:18 pm

The newly added foreach loop will allow me to apply the code to 5 tickets.

What’s actually allowing you to apply the code to 5 tickets is the change to the ticket scope from event scope (the first part of the custom code). The newly added foreach loop only adds to increment the count of promo code uses.

You can add a conditional to the top of the innermost loop and that will prevent going over the limit:

if($promotion->get('PRO_uses') <= $promotion->redeemed() + 1) {

Normally the above check isn’t needed because only one scope item would be applied regardless of the number of tickets.

October 15, 2019 at 7:58 pm

It still allows that extra ticket to work with the code. Did I place it in the correct loop?

foreach ($ticket_line_items as $ticket_line_item) {
    if (! $ticket_line_item instanceof EE_Line_Item) {
    foreach ($applicable_promotion_tickets as $promotion_ID => $promotion_tickets) {
       <strong> if($promotion->get('PRO_uses') <= $promotion->redeemed() + 1) {

        // rest of code

October 15, 2019 at 8:00 pm

Sorry, in the above code block I tried to bold the added code to emphasize its placement. “” and “” isn’t in my actual code.


  • Support Staff

October 16, 2019 at 10:25 am

It still allows that extra ticket to work with the code.

Can you explain what you mean by this? It may help to know the exact scenario you’re testing because I’m probably not testing the changes the same way you’re testing. If you can outline a list of testing steps we can examine further.

October 22, 2019 at 5:11 pm

Here is a link to the staging version of the Event Espresso integration –

The promo code AMERCOMP applies only to “Early Registration” and “Early Registration & Microgrid Tour”. It’s a dollar discount of $895 and it can only be used 4 times.

With those settings, the expectation is that it should only apply to the first 4 tickets and any additional tickets are full price. However, in a single transaction I can checkout with 5 tickets and the discount will apply to all.


  • Support Staff

October 29, 2019 at 12:49 pm


I’m sorry for the delay. I did some refactoring on the parts that add usage monitoring which will avoid the above scenario. Here’s a gist that includes all the changes:

The support post ‘Discount by Tickets’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Support forum for Event Espresso 3 and Event Espresso 4.
Documentation for EE3 and EE4
Documentation for Event Espresso 3 Documentation for Event Espresso 4

Status: closed

Updated by  Josh 9 months, 1 week ago ago

Topic Tags


This topic is: not resolved
Do NOT follow this link or you will be banned from the site!