Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing Price from Action/Filter Hook - On Step 2: Single Registration Page #240

Closed
travisfont opened this issue Sep 11, 2017 · 5 comments
Assignees

Comments

@travisfont
Copy link

travisfont commented Sep 11, 2017

Is this a bug report?

  • [x ] yes
  • [x ] no

(you tell me...)

What branch did this occur in?

master from 4.9.31.p Version 4.8.1

What version of WordPress is on the site this issue happened?

4.8.1 (self-hosted)

Please reference this page:
https://eventespresso.com/topic/changing-price-from-actionfilter-hook/#post-250823
AND
https://gist.github.com/tfont/4045cdd1736fa853bd9bd60b7d6333d9

Problem:

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. In the processing of changing this price. I've tried the above methods to change the pricing on the transaction, however, it remains the same.

Please let me know if I can provide any additional information.

@mnelson4
Copy link
Contributor

Hi @tfont I provided some feedback on https://gist.github.com/tfont/4045cdd1736fa853bd9bd60b7d6333d9, although that might not be the cause of your problem.

@travisfont
Copy link
Author

travisfont commented Sep 13, 2017

@mnelson4 so far no. I left an update on the GIST. I am trying to figure out the entire EE_SPCO_Reg_Step_Attendee_Information class and its interactions to better debug my problem.

@mnelson4
Copy link
Contributor

hi @tfont I'm having difficulty following what you're asking on that gist. Can you please show your entire plugin code? That would help me identify the problem

@travisfont
Copy link
Author

Sadly, not possible. It's pretty straightforward:

When submitting on step 2 which then goes on to step 3. How would one change the price of a transition (item) that will display this price change on step 3 and onwards?

Please see:
https://gist.github.com/tfont/4045cdd1736fa853bd9bd60b7d6333d9#gistcomment-2201375

mnelson4 pushed a commit to eventespresso/ee-code-snippet-library that referenced this issue Sep 19, 2017
@mnelson4
Copy link
Contributor

@tfont it's much harder for us to help debug your code if you don't show us what it is.

Here is a code snippet that I've confirmed changes the transaction's total and the amount show during SPCO's payment options step (what you're calling step 3):

add_action('AHEE__Single_Page_Checkout__after_attendee_information__process_reg_step', 'custom_hook', 10, 1);
function custom_hook(EE_SPCO_Reg_Step_Attendee_Information $data)
{
    $purchases = $data->checkout->transaction->items_purchased();
    $first_item = reset($purchases);
    //we need to edit the sub-item's unit price, as
    //the line item's total is calculated from its sub-items
    $children = $first_item->children();
    $child_line_item = reset($children);
    $child_line_item->set('LIN_unit_price', 10);
    $data->checkout->cart->get_grand_total()->recalculate_total_including_taxes();
    $data->update_checkout();
}

Added this as a new code snippet on https://github.com/eventespresso/ee-code-snippet-library/blob/master/checkout/mn_spco_change_line_item_before_payment_options_step.php

If you would like more help, please provide the code you're using.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants