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

update chosen payment method soon, in wc_ajax_update_order_review #29248

Closed
wants to merge 7 commits into from

Conversation

marian-kadanka
Copy link
Contributor

@marian-kadanka marian-kadanka commented Feb 28, 2021

All Submissions:

Changes proposed in this Pull Request:

I had to write code adding payment method based fee to the cart, during checkout, hooking into the woocommerce_cart_calculate_fees hook. I was hoping that value of WC()->session->get( 'chosen_payment_method' ) already reflects the new value, but it is not always the case, specifically in the case of payment methods available only for some of the shipping methods. In this case, during woocommerce_cart_calculate_fees run, the value of WC()->session->get( 'chosen_payment_method' ) is one posted with the AJAX call - the old payment method selected, not the one we are going to update based on the currently running wc_ajax_update_order_review AJAX request.

So to resolve this issue, let's update chosen payment method soon, so code hooked in cart totals calculation, like those calculating cart fees, can operate with the current value.

Other information:

  • Have you added an explanation of what your changes do and why you'd like us to include them?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?

Changelog entry

Enter a summary of all changes on this Pull Request. This will appear in the changelog if accepted.

update chosen payment method soon, in wc_ajax_update_order_review

@roykho
Copy link
Member

roykho commented Apr 5, 2021

Hi @marian-kadanka - Thanks for the PR however I am not entirely sure what you mean by it does not set the payment method chosen at the time of the AJAX call? It does so here https://github.com/woocommerce/woocommerce/blob/trunk/includes/class-wc-ajax.php#L313

@roykho roykho added the needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. label Apr 6, 2021
@ObliviousHarmony ObliviousHarmony added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Feb 21, 2022
@peterfabian
Copy link
Contributor

Hi @marian-kadanka ,

Thanks for your contribution and apologies for taking a long time to respond to your request. Can you please give more details about the setup of shipping and payment gateways (ideally with screenshots of your settings) so that we better understand your use case?

From a high level, this makes sense in some cases, where, as you said, payment gateways depend upon the shipping method chosen.

However, I could see it also working the other way around in some markets where shipping methods depend on the chosen payment type.

That's why we'd like to have a good understanding of your specific use case and setup before proceeding further.

Thanks,
Peter.

@barryhughes
Copy link
Member

Hi @marian-kadanka,

We're still lacking some clarity so, given how long this work has been sitting without an update, we'll go ahead and close it.

Of course, if you are still interested in this please don't hesitate to create a new PR, or even start with a new enhancement request where we can discuss it (if you prefer) before deciding on the best approach.

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs: author feedback The issue/PR needs a response from any of the parties involved in the issue. plugin: woocommerce Issues related to the WooCommerce Core plugin. type: community contribution
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants