Support

Home Forums Event Espresso Premium Online only discount

Online only discount

Posted: December 3, 2017 at 5:55 pm


Scratch Digital

December 3, 2017 at 5:55 pm

Hi

I am trying to add an online only discount for all events. so all order through the website would receive a automatic discount but all orders through the admin panel (ie. phone order done my staff) no discount is applied. to promo users to use the website and not call us.

I see codeless promotion will automatically apply a discount which is great but this is also applied when making a booking through the admin panel.

So from want i can see i have 2 options either:
1. writing a function to remove promotions from being applied when booked through the admin
2. writing a function to automatically apply a coded promotion when booking through the frontend.

Do you have any thoughts on how i should approach this problem, or a non custom function way to do this?

Thanks
Jonathan


Tony

  • Support Staff

December 4, 2017 at 5:07 pm

Hi Jonathan,

The approach I would take is #1, its easier to remove a function than it is to add your own…. which would be doing the same thing as the promotions add-on anyway.

Luckily, this is actually fairly simple to do.

So if your in the admin you don’t want promotions to apply to the cart meaning an is_admin() check is needed, however, all WP ajax requests return true for is_admin() meaning we need to check explicity for ajax requests (the front end uses ajax to apply the promotions) so we also need ! (defined('DOING_AJAX') && DOING_AJAX).

Then if those conditions are true, remove the action the Promotions add-on sets to automatically process promotions on in the cart:

remove_action(
    'FHEE__EE_Ticket_Selector__process_ticket_selections__before_redirecting_to_checkout',
    array( 'EED_Promotions', 'auto_process_promotions_in_cart' )
);

Hook that remove call into something that loads later in the request than the promotion adds the call, for example ‘init’ and that should be it.

All together that looks like this:

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

Add that function to a Custom Functions Plugin on your site and test both a front end registration and one add via the admin.

The support post ‘Online only discount’ 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  Tony 1 year, 9 months ago ago

Topic Tags

Tagged: 

Notifications

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