Support

Home Forums Event Espresso Premium Promotion Codes Not Working

Promotion Codes Not Working

Posted: August 25, 2021 at 1:06 pm


corelearn

August 25, 2021 at 1:06 pm

Hello! We have the promotions add-on installed and it has worked well for years. Suddenly, none of our promotion codes are being accepted. We get an error that says:
We’re sorry but the promotion code “FREEOERA” could not be applied to any Events.”

We have checked the settings and made sure the codes are set to unlimited use for all events.

Any suggestions for fixing this error?

Thanks!
Emily


Tony

  • Support Staff

August 25, 2021 at 2:07 pm

Hi Emily,

Can you post a screenshot of the settings for your promotion code, please?

https://eventespresso.com/wiki/troubleshooting-checklist/#screenshots

(Note you can set your post to be private if preferred)

Or, if you prefer for me to look at it directly just send over temp login details using this form:

https://eventespresso.com/send-login-details/


corelearn

August 30, 2021 at 4:00 pm

This reply has been marked as private.


Hazel Apuhin

August 31, 2021 at 4:14 am

Hi Emily,

I hope you are well.

We received your login details. Thank you!

Yes, it is working. We are working on it now.

Thanks for your patience.


Hazel Apuhin

September 1, 2021 at 1:42 pm

Hi,

I can see that you have a caching plugin installed, called WP Rocket. This could be causing issues because sometimes the registration pages get cached on the server.

I can see that when I go to one of your events and found this in the right sidebar:

https://www.screencast.com/t/7Lq4HEdZ

Try clearing the cache and excluding the event pages from the cache.

Please refer to the steps in the link below under “Setup no-cache/exclusion rules for WP Rocket”

https://eventespresso.com/wiki/setup-nocache-exclusion-rules-event-espresso/

Then try testing the promo codes again.

Did this help?


corelearn

September 2, 2021 at 8:46 am

This reply has been marked as private.


Tony

  • Support Staff

September 3, 2021 at 11:00 am

Hi Emily,

My apologies for the delayed reply.

I’ve just added a couple of test registrations to one of your events using the promotion code in your opening post, which worked as expected.

Is there a specific event you are testing this on?


Tony

  • Support Staff

September 3, 2021 at 11:01 am

Note I’ve left the registrations on your site simply so you can see they processed, if you’d like to remove those please feel free.

If you prefer I remove them just let me know.


corelearn

September 6, 2021 at 12:10 pm

This reply has been marked as private.


corelearn

September 7, 2021 at 9:39 am

Hi Tony! I also wanted to add that I tried registering with FREEOERA and still got the error message.

Emily


Hazel Apuhin

September 7, 2021 at 9:43 am

Hi Emily,

I am sorry to hear that you are still getting the promo code error.

Sounds like you are having a caching issue still since Tony was able to apply the code without a problem. To test, you can try doing it in a device that you haven’t used to apply the promo code.

Did this work?

If yes, go back to the computer you got the error from and follow these steps:

In Chrome
1. On your computer, open Chrome.
2. At the top right, click More.
3. Click More tools. Clear browsing data.
4. At the top, choose a time range. To delete everything, select All time.
5. Next to “Cookies and other site data” and “Cached images and files,” check the boxes.
6. Click Clear data.
7. Relaunch Chrome

Try the registration and apply the promo code.

Does this help?

Thanks!


corelearn

September 7, 2021 at 10:22 am

This reply has been marked as private.


Tony

  • Support Staff

September 7, 2021 at 12:33 pm

This reply has been marked as private.


corelearn

September 8, 2021 at 6:16 am

This reply has been marked as private.


Tony

  • Support Staff

September 8, 2021 at 10:48 am

Hi Emily,

I’ll explain a little on how the promotions are applied so this makes more sense.

When a promotion code is submitted, EE first pulls the promotion object itself based on the code supplied.

What it does then works out if your cart has ‘items’ that are applicable to the current promotion it pulled from the above. It does this by first pulling all event objects in your current cart and saving them to an $events variable.

Then using the promotion object from above it pulls any objects (Events) that promotion applies to and saves those to a $redeemable_scope_promos variable.

As it now has both of those it can compare the $redeemable_scope_promos with the items you have in the cart to get the $applicable_items. So $applicable_items is any items you have in your cart that are also set on the promotion code for it to apply to.

After that, it filters $applicable_items to allow other plugins to hook in and change those items on the fly for whatever scenario they prefer, that filter is what the custom code on your site is using.

Now, the specific error you are getting when submitting the promotion codes in question means that $applicable_items is empty, but when I test your promotion codes set up exactly the same as how yours are on my test sites, they work fine. So we need to know if the issue is with the custom code you currently have hooking into work out the $applicable_items or something else.

When I mentioned disabling that custom plugin, I meant disable it for long enough for you to submit a promotion code that you know currently does not work and see if it works then. If you then re-enable the plugin and the same promotion code no longer works, there is an issue with what that custom plugin is doing which will need to be fixed.

—-

Is there a setting that is different within those two promo codes that is not working with the custom plug-in?

I can’t answer that as I didn’t write that custom plugin, I can tell you that the custom code you have is basically pulling ALL promotions on the site, looping over them all to get the ID’s for each of them. Like so:

$promotions = $promotionsinstance->get_all();
foreach ( $promotions as $p ) {
    $id = $p->id();   
    array_push($promoids,$id);
}

Then looping over ALL EE events and pulling available tickets to do the same, loop over them and pull their ID’s:

$args = array( 'post_type' => 'espresso_events');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) { 
    $loop->the_post();
    $eventid = get_the_ID();
        	
    $tickets = EEH_Event_View::event_tickets_available( $eventid );
    foreach ( $tickets as $ticket ) {	
        $tid = $ticket->ID();
        array_push($ticketids,$tid);
    }
}

Then using array_fill_keys() to build and array of promotion ID’s that applies to every active ticket:

$allpromosandtickets=array_fill_keys($promoids,$ticketids);

Then filtering FHEE__EED_Promotions__get_applicable_items__applicable_items using $allpromosandtickets to work out if promotions are applicable and using a snippet we provided a while back as an example of ‘Ticket’ scopes on promotions to apply promotions to tickets:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/addons/eea-promotions/bc_ee_ticket_scope_promotions.php

There’s a lot going on in that function that can be narrowed so it only works on the current events/tickets/promotion code in the cart before it passes anything to the function I linked above in $allpromosandtickets which may help here.

Ideally, you need a custom plugin that creates a ‘ticket’ scope for the promotions add-on as current it runs on everything.

I created another new promo code yesterday (webinar10) that appears to be working. What is different about FREEOERA2021 and CCC2021?

As far as I can tell, nothing, which is why you need to test this without that custom plugin running to narrow down if the issue is with the promotion itself or the custom code (I suspect it’s the latter).


corelearn

September 8, 2021 at 11:37 am

This reply has been marked as private.


Tony

  • Support Staff

September 8, 2021 at 2:55 pm

1. Do you have any thoughts on why this plug-in just now started to interfere and why it’s only interfering with certain promo codes? We’ve been using it for more than two years now without issue?

Looking at the working codes it looks like the promotions that are set to be global work but any set for individual events/groups of events don’t.

The code needs to be debugged properly to know what each variable holds to know more.

2. What are next steps for troubleshooting & fixing the issue so that we’re able to apply discounts per ticket rather than to a subtotal?

As this isn’t an issue with Event Espresso itself we would recommend you contact the author of the plugin to troubleshoot their code and fix this.

The snippet they are using from our repo was intended to allow promotions to apply to certain tickets which has then been put together by pulling in everything to pass to the function which basically then makes it more complicated than it needs to be.

Just to clarify, you’re trying to get ALL promotions on your site to apply on a per ticket basis rather than per transaction?

You must be logged in to reply to this support post. Sign In or Register for an Account

Event Espresso