Support

Home Forums Event Espresso Premium Applying multiple transaction surcharges

Applying multiple transaction surcharges

Posted: June 25, 2019 at 9:17 pm

Viewing 4 reply threads


Patrick

June 25, 2019 at 9:17 pm

Hi EE Team,

I was able to customize the bc_ee_apply_transaction_surcharge.php snippet to suit my needs. Each transaction surcharge function group works great individually.

But, when I am trying to apply 2 transaction surcharge function groups on the same registration form, one is blocking the other from firing.

I have tried :
1) Renaming almost all variables, filters and function names on the second function group.
2) Assigning different action priorities :


add_action( 'AHEE__EE_System__core_loaded_and_ready', 'bc_ee_determine_whether_to_apply_surcharge', 10 );
add_action( 'AHEE__EE_System__core_loaded_and_ready', 'bc_ee_determine_whether_to_apply_surcharge_don', 20 );

3) Assigning different filter priorities :


add_filter( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', 'rc_ee_apply_transaction_surcharge_don', 10 );
add_filter( 'FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout', 'rc_ee_apply_transaction_surcharge_don', 20 );

Would you please give me some directions as of how I can run multiple occurrences of the bc_ee_apply_transaction_surcharge.php snippet on a single registration form ?

Thanks in advance.

Patrick

  • This topic was modified 5 years, 3 months ago by Tony. Reason: code fix


Patrick

June 25, 2019 at 9:20 pm

Sorry for the presentation, I thought the triple backticks would wrap the code correctly…


Josh

  • Support Staff

June 26, 2019 at 12:11 pm

Hi,

You don’t need to (and probably should not) change the filter priorities and variable names.

You also do not change FHEE__EED_Single_Page_Checkout___initialize_checkout__checkout, that’s a core filter hook so if you change it, your code will not execute.

When building out your code for a second surcharge, you’ll change the function names and any custom filter hook names. An example of a custom filter hook from the code example is the
FHEE__bc_ee_apply_transaction_surcharge__surcharge_details
filter hook.


Patrick

June 26, 2019 at 7:09 pm

Thanks Josh !

I have cleaned my code as per your instructions.

Both surcharges are now working as expected except for one special case :

Let say I have a ticket of 20$. For some guests, I am applying a negative surcharge to simulate a discount (guest1 = -10$, guest2 = -15$, guest3 = -20$) based on a dropdown selection menu. The second surcharge is a variable donation (positive integer). If I apply the first surcharge for guest3, which is equivalent to a 100% discount, then the result of the second surcharge is always 0 independently of user donation. In fact, whenever a first surcharge results in a null calculation from the recalculate_total_including_taxes() function, the second surcharge is not applied.

Now, when inverting both functions in my custom plug-in, i.e. applying “Donation” surcharge prior to applying “Discount” surcharge, everything works as expected, even the case described earlier.

Any clues or recommendations ?

Thanks in advance.


Josh

  • Support Staff

June 27, 2019 at 9:57 am

You could try changing the LIN_order parameters (passed to add_child_line_item() ) to see if having one apply before the other makes any difference.

Viewing 4 reply threads

The support post ‘Applying multiple transaction surcharges’ 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