Support

Home Forums Event Espresso Premium Changing Price from Action/Filter Hook

Changing Price from Action/Filter Hook

Posted: September 7, 2017 at 10:19 am


lola communication

September 7, 2017 at 10:19 am

Which action or filter hook would I use to change the price on the 3rd page (Payment Options) when registering for an event.

I see a lot of actions on this page, just not sure which one? Or perhaps a filter?

Ideally, I have a special email that I want to put on the hook (will never change). And if the user had used this special email the price would change, hence using the hook to change the price on the 3rd page.


Josh

  • Support Staff

September 7, 2017 at 10:29 am

The
AHEE__Single_Page_Checkout__before_payment_options__process_reg_step
action hook will allow for changing the price there.


lola communication

September 8, 2017 at 3:54 am

Thanks, Josh. Is there a link to documentation for this hook? I see tons of protected objects and arrays which I would presume are all different types of methods…


lola communication

September 8, 2017 at 4:03 am

I realized that I could inject the EE_SPCO_Reg_Step_Payment_Options object into the parameters and receive all the chain methods with an IDE.

If a link is available! I wouldn’t mind it thought :]


Josh

  • Support Staff

September 8, 2017 at 6:46 am

Hi Lola Communication,

I’m curious to know what documentation for a hook would look like? Maybe this example code that shows a way to use the hook will help:

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


lola communication

September 8, 2017 at 8:04 am

I just realized that this hook only allows changing after step 3 is submitted/processed.

However, I am looking for after step 2 is submitted/processed and on step 3 I would be allowed to change the pricing. This would have the changed pricing shown in step 3 rather than after step 3 is submitted/processed.

A bit funky, but I hope that’s not confusing.. Testing other hooks as I see them in order, but so far no luck!


Josh

  • Support Staff

September 8, 2017 at 8:09 am

You could try this one instead:

AHEE__Single_Page_Checkout__after_attendee_information__process_reg_step


lola communication

September 11, 2017 at 7:14 am

This is the correct hook, thank you!

However, I’m still trying to figure out how to change pricing and specific transaction information on the submission.

I’ve tried so far:


public static function custom_hook(EE_SPCO_Reg_Step_Attendee_Information $data)
{
$first_key = key($data->checkout->transaction->items_purchased());

$data->checkout->transaction->items_purchased()[$first_key]->set('LIN_unit_price', 10);
$data->checkout->transaction->items_purchased()[$first_key]->recalculate_total_including_taxes();

$data->checkout->transaction->set('LIN_unit_price', 10);

$data->checkout->cart->get_grand_total()->set('LIN_unit_price', 10);
$data->checkout->cart->get_grand_total()->recalculate_total_including_taxes();

$data->update_checkout();

// actually cause false return error
$data->checkout->transaction->set('LIN_unit_price', 10));
$data->checkout->transaction->save(array('LIN_unit_price', 10));
}

None of the above methods seem to work. This is the lack of docs part 😉


lola communication

September 11, 2017 at 7:17 am

Sorry for the ugly format.

Use this below link for better preview:
https://gist.github.com/tfont/4045cdd1736fa853bd9bd60b7d6333d9


Josh

  • Support Staff

September 11, 2017 at 9:16 am

You actually have one too many brackets on this line:

$data->checkout->transaction->set('LIN_unit_price', 10));

I can suggest starting a github issue here:

https://github.com/eventespresso/event-espresso-core/issues

and one of the developers can follow up with any further questions you may have.


lola communication

September 11, 2017 at 9:31 am

That was just a typo, sorry.

So, out of curiosity which method should have updated the pricing then?


Josh

  • Support Staff

September 11, 2017 at 9:36 am

I can advise that you start a github issue here:
https://github.com/eventespresso/event-espresso-core/issues
and one of the developers can follow up with any further questions you may have.


lola communication

September 11, 2017 at 10:10 am

Okay, just made one! I don’t believe it’s a bug though. Just a matter of understanding all the available methods and object cases.


Josh

  • Support Staff

September 11, 2017 at 10:14 am

I went ahead and labeled your issue report as a “question”.

The support post ‘Changing Price from Action/Filter Hook’ 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  Josh 2 years, 2 months ago ago

Topic Tags

Notifications

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