Skip to content

Commit 9a5a96b

Browse files
wjrosadiegocurbelo
authored andcommitted
Fix order received text filter when order object is invalid (#4074)
* Fix order received text filter when order object is invalid * Adding unit tests * Changelog and readme entries
1 parent 3ee2453 commit 9a5a96b

File tree

4 files changed

+15
-6
lines changed

4 files changed

+15
-6
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* Fix - Temporarily disables the subscriptions detached notice feature due to long loading times on stores with many subscriptions.
55
* Fix - Update ACH capability check key
66
* Fix - Update legacy checkout documentation links and deprecation notice display logic
7+
* Fix - Fixes an error with the `filter_thankyou_order_received_text` filter when it does not receive a valid WC_Order instance.
78

89
= 9.3.0 - 2025-03-13 =
910
* Dev - Adds a new README.md file to the plugin with specific development-focused instructions.

includes/payment-methods/class-wc-stripe-upe-payment-gateway.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2956,11 +2956,11 @@ public function filter_my_account_my_orders_actions( $actions, $order ) {
29562956
* Filter the order received text for Amazon Pay orders, including the delayed confirmation information.
29572957
*
29582958
* @param string $text Default text.
2959-
* @param WC_Order $order Order data.
2959+
* @param WC_Order|bool $order Order data.
29602960
* @return string
29612961
*/
29622962
public function filter_thankyou_order_received_text( $text, $order ) {
2963-
if ( $order->get_payment_method_title() === 'Amazon Pay (Stripe)' && $order->has_status( 'pending' ) ) {
2963+
if ( is_a( $order, 'WC_Order' ) && $order->get_payment_method_title() === 'Amazon Pay (Stripe)' && $order->has_status( 'pending' ) ) {
29642964
$text .= '<p class="woocommerce-info">';
29652965
$text .= esc_html( 'The payment is being processed and it might take a few minutes before it\'s confirmed.' );
29662966
$text .= '</p>';

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,5 +114,6 @@ If you get stuck, you can ask for help in the [Plugin Forum](https://wordpress.o
114114
* Fix - Temporarily disables the subscriptions detached notice feature due to long loading times on stores with many subscriptions.
115115
* Fix - Update ACH capability check key
116116
* Fix - Update legacy checkout documentation links and deprecation notice display logic
117+
* Fix - Fixes an error with the `filter_thankyou_order_received_text` filter when it does not receive a valid WC_Order instance.
117118

118119
[See changelog for all versions](https://raw.githubusercontent.com/woocommerce/woocommerce-gateway-stripe/trunk/changelog.txt).

tests/phpunit/payment-methods/test-class-wc-stripe-upe-payment-gateway.php

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,15 +2834,22 @@ public function payment_method_titles_provider() {
28342834
* @return void
28352835
*/
28362836
public function test_filter_thankyou_order_received_text() {
2837+
$default_text = 'Thank you. Your order has been received.';
2838+
2839+
// Order is invalid.
2840+
$actual = $this->mock_gateway->filter_thankyou_order_received_text( $default_text, false );
2841+
$expected = $default_text;
2842+
2843+
$this->assertEquals( $expected, $actual );
2844+
2845+
// Order exists.
28372846
$order = WC_Helper_Order::create_order();
28382847
$order->set_status( 'pending' );
28392848
$order->set_payment_method_title( 'Amazon Pay (Stripe)' );
28402849

2841-
$default_text = 'Thank you. Your order has been received.';
2842-
2843-
$actual = $this->mock_gateway->filter_thankyou_order_received_text( $default_text, $order );
2844-
2850+
$actual = $this->mock_gateway->filter_thankyou_order_received_text( $default_text, $order );
28452851
$expected = $default_text . '<p class="woocommerce-info">The payment is being processed and it might take a few minutes before it&#039;s confirmed.</p>';
2852+
28462853
$this->assertEquals( $expected, $actual );
28472854
}
28482855

0 commit comments

Comments
 (0)