-
Notifications
You must be signed in to change notification settings - Fork 219
Fix - "Order received" page does not display the payment method information. #9092
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you very much for working on this, @iamdharmesh! 🙌
While the fix works as expected, I'd like to get a second review from @mikejolley, who has deeper knowledge about the Store API. What surprises me in this particular case, is the history of the line you changed:
This PR
$this->order->set_payment_method( $this->get_request_payment_method( $request ) ); |
Jan 5, 2022
$this->order->set_payment_method( $this->get_request_payment_method_id( $request ) ); |
Oct 26, 2021
$this->order->set_payment_method( $request['payment_method'] ?? '' ); |
Sep 28, 2021
$this->order->set_payment_method( $this->get_request_payment_method( $request ) ); |
Dec 2, 2020
$this->order->set_payment_method( $this->order->needs_payment() ? $this->get_request_payment_method( $request ) : '' ); |
@mikejolley Would you mind taking a look at this case?
QA/Test Report- ✅Testing Environment -
Steps to Test- Steps to test this PR:
Test Results - This pull request has been tested and found to be functional in resolving the aforementioned issue. Payment method is now appearing consistently across all relevant areas, including the Order Confirmation Thank You Page, Order Listing page in wp-admin, and Email sent to the customer upon successful payment. All relevant test cases have passed successfully. Functional Demo / Screencast - Before Fix- Woo.Contri.-.Before.Fix.mp4After Fix- Woo.Contri-.After.Fix.mp4Negative Test - To ensure new change doesn't break already working functionality. Negative.Test.mp4QA Status- Pass ✅ |
@nielslange @iamdharmesh Looking back at the last major change in #5440, both functions were changed so that /**
* Set the payment method.
*
* @param string $payment_method Supports WC_Payment_Gateway for bw compatibility with < 3.0.
* @throws WC_Data_Exception Throws exception when invalid data is found.
*/
public function set_payment_method( $payment_method = '' ) {
if ( is_object( $payment_method ) ) {
$this->set_payment_method( $payment_method->id );
$this->set_payment_method_title( $payment_method->get_title() );
} elseif ( '' === $payment_method ) {
$this->set_prop( 'payment_method', '' );
$this->set_prop( 'payment_method_title', '' );
} else {
$this->set_prop( 'payment_method', $payment_method );
}
} However, while this does state that the method is for bw compatibility and not deprecated, the type defined by the docblock suggests that we should be passing a string. The other concern is that there may be an edge case issue where there is no payment method. This would result is us passing I think there are 2 options to resolve this.
How does this sound? |
Thanks for the detailed explanation @mikejolley, I have updated PR as per 2nd option. Could you please help to review it once? Thanks |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making those changes. This fixes the original issues and any potential edge cases. 👍🏻
e2e tests passing. The failing tests are relating to forks/permission issues, so ignoring. Merging this now 👍🏻 |
This PR contains a minor change to fix #8448. Currently, when we place an order using the checkout block, the payment method title information not getting saved to the order and it results in payment method information is not showing on Order received page and backed order list page as described in the reported issue.
This was happening due to we are passing the payment method ID in
set_payment_method()
in theupdate_order_from_request
function so, Payment method title is not getting updated for orders. This PR updates it to pass the payment method object to update the payment method title to order.Fixes #8448
Accessibility
prefers-reduced-motion
Other Checks
Screenshots
Testing
Automated Tests
User Facing Testing
WooCommerce Visibility
Performance Impact
Changelog