Support

Home Forums Event Espresso Premium Programmatically apply a coupon

Programmatically apply a coupon

Posted: December 28, 2023 at 9:12 am

Viewing 5 reply threads


dreamimplementation

December 28, 2023 at 9:12 am

Is there a way to to programmatically apply an existing coupon? I would like to add it via a function defined in a hook in functions.php


Rio

  • Support Staff

December 28, 2023 at 8:40 pm

We have upcoming feature coming, wherein you can copy a link with a coupon code in it. That feature is under testing and it will be roll out soon.

Is the one you’re requesting similar with Non-coded promotion?
https://eventespresso.com/wiki/ee4-promotions-add-on/ but that automatically applied to your selected events.

thanks


dreamimplementation

December 29, 2023 at 1:23 am

So I would like to create a function in the theme functions.php file that triggers after the first step of the ticket selection has been done. The goal is that if a certain condition has been met, that a predefined coupon is applied. Something that would look like this in code:


$cart->apply_coupon_code('PREDEFINED_COUPON_CODE');

Would this be possible?


Tony

  • Support Staff

January 4, 2024 at 7:23 am

Hi there,

We don’t currently have an option to apply a promo code to the cart in the way you are requesting above as it is expected to go through he promotions add-on.

It would be possible to add the promotions but you would need to create a custom function to apply the promotions to the transaction, we don’t have a function/method you can pass a promotion code to which would then apply the promotion for you outside of the promotions add-on itself.


dreamimplementation

January 5, 2024 at 4:11 am

This reply has been marked as private.


Tony

  • Support Staff

January 5, 2024 at 4:45 am

Hi there,

I can only apologise for the delay during the new year holidays. During Christmas and New Year we all spend a little time with our families so response times are a little longer than usual.

In any case, I’m glad you’ve found a solution.

Viewing 5 reply threads

The support post ‘Programmatically apply a coupon’ 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.

Event Espresso