Support

Home Forums Event Espresso Premium Deduct amount based on registration form

Deduct amount based on registration form

Posted: September 15, 2020 at 7:34 am

Viewing 11 reply threads


He Zhengrui

September 15, 2020 at 7:34 am

Hi there,

I’m trying to create a field in the registration form where the user will input a number(e.g 300) and it will be deducted based on the input at the checkout page.

May I know how do I go about it?


Tony

  • Support Staff

September 16, 2020 at 3:03 am

Hi there,

This is not something we have available within core but take a look at the snippet here:

https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/bc_ee_add_product_surcharge.php

That is used to add a surcharge based on the users input and you can do the same with a discount by making the unit_price in that snippet negative.


He Zhengrui

September 16, 2020 at 7:32 am

@Tony,

Thanks for pointing me in the right direction.

Right now, I have a different surcharge as well labeled payment method, where there is a 3.5% surcharge if they pay by credit card.

However, it is not in the right order, I would like to have the credit card surcharge applied last.

May I know how do I change the order of the invoice?


Tony

  • Support Staff

September 17, 2020 at 11:10 am

Which code are you using to add the surcharge?

If I’m understanding th question correctly, you should just be able to set the 'LIN_order' value to something higher than your other line items surcharges when you add it to the transactions line items.


He Zhengrui

September 17, 2020 at 8:51 pm

Hi Tony,

Thanks for your kind reply once again.

I think that is correct actually, but whenever I modify it still does not change the order of the items.

Please see code in this link here below

https://gist.github.com/hzr1990/58afed24a69a76074218e1448c57c6c4

And the screenshot here

https://ibb.co/ts1wW3L


Tony

  • Support Staff

September 18, 2020 at 4:46 am

Have you applied a higher LIN_order?

Right now it looks like its set to 1, try 100, does it apply correctly then?


He Zhengrui

September 18, 2020 at 5:09 am

Hi Tony,

Thanks for the kind reply

For the item I want to be at the top, I tried applying numbers from ‘0’ to ‘-1000’

whereas for the item i want to apply last, I tried applying numbers from ‘1’ to ‘99999’


Tony

  • Support Staff

September 18, 2020 at 5:16 am

For the item I want to be at the top, I tried applying numbers from ‘0’ to ‘-1000’

?? Which items?

EE automatically orders line items as they are added so if you are changing that for various items you’ll likely start running into weird issues.

whereas for the item i want to apply last, I tried applying numbers from ‘1’ to ‘99999’

The order is only set when the line item is added, so I’m just checking that you are adjusting the code and then simply refreshing the page to confirm? Set LIN_Order to say 100 on your payment method surchage code then clear your session by visiting /registration-cancelled/

Start a new registration and work through to reapply the surcharge, it still doesn’t apply correctly?


He Zhengrui

September 18, 2020 at 5:22 am

This reply has been marked as private.


He Zhengrui

September 26, 2020 at 8:48 am

Hi Tony! you may have missed my previous message or escalated it further.

Any updates so far?

Thanks!


He Zhengrui

October 8, 2020 at 2:39 am

Hi Guys,

Any updates?


He Zhengrui

October 17, 2020 at 7:17 am

Hi guys, any updates?

Please see the reply again below.

Hi Tony,

Thanks for the prompt reply. Sorry I was not being detailed in what I applied the numbers from.

What I meant was for bc_ee_add_product_surcharge I set the LIN_order to ‘100’ and for bc_ee_apply_transaction_surcharge I set the LIN_order to ‘999’

The two numbers were added into the array under the method add_child_line_item(EE_Line_Item::new_instance( array(

I tried your method and data seems to be cleared but it does not seem to work either. My understanding is that the code runs whenever the form is submitted, not on the finalize registration page itself, so whenever i modified the code i went back and restart the registration process all over again.

To provide more clarity,https://thebeverageclique.com/events/wset-level-1-test/

Thanks in advance!

Viewing 11 reply threads

The support post ‘Deduct amount based on registration form’ 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