Skip to content

Commit 27475b4

Browse files
authored
Set order payment method title to the customisable title setting rather than the label (#3481)
* Use customisable title rather than label to set order's payment method title * Add changelog entires * Add unit test to verify custom payment method titles * Remove tests which verify subscriptions
1 parent e07054e commit 27475b4

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

changelog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
* Fix - Pre-orders set to pay upon release were remaining pending when attempting to pay using Stripe.
2525
* Fix - Ensure subscription renewal order statement descriptors include the order number suffix.
2626
* Fix - Resolved an issue which caused the WeChat Pay payment icon to not be displayed on shortcode checkout pages.
27+
* Fix - Set order payment method title to the customizable title setting rather than the default label.
2728

2829
= 8.7.0 - 2024-09-16 =
2930
* Add - Introduces a new promotional surface to encourage merchants with the legacy checkout experience and APMs enabled to use the new checkout experience.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1618,7 +1618,7 @@ public function set_payment_method_title_for_order( $order, $payment_method_type
16181618
return;
16191619
}
16201620
$payment_method = $this->payment_methods[ $payment_method_type ];
1621-
$payment_method_title = $payment_method->get_label();
1621+
$payment_method_title = $payment_method->get_title();
16221622
$payment_method_id = $payment_method instanceof WC_Stripe_UPE_Payment_Method_CC ? $this->id : $payment_method->id;
16231623

16241624
$order->set_payment_method( $payment_method_id );

readme.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,5 +152,6 @@ If you get stuck, you can ask for help in the Plugin Forum.
152152
* Fix - Pre-orders set to pay upon release were remaining pending when attempting to pay using Stripe.
153153
* Fix - Ensure subscription renewal order statement descriptors include the order number suffix.
154154
* Fix - Resolved an issue which caused the WeChat Pay payment icon to not be displayed on shortcode checkout pages.
155+
* Fix - Set order payment method title to the customizable title setting rather than the default label.
155156

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

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

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2379,4 +2379,33 @@ public function test_set_payment_method_title_for_order() {
23792379
$this->assertEquals( 'stripe', $mock_subscription_0->get_payment_method() );
23802380
$this->assertEquals( 'stripe', $mock_subscription_0->get_payment_method() );
23812381
}
2382+
2383+
/**
2384+
* Test test_set_payment_method_title_for_order with custom title.
2385+
*/
2386+
public function test_set_payment_method_title_for_order_custom_title() {
2387+
$order = WC_Helper_Order::create_order();
2388+
2389+
// CARD
2390+
// Set a custom title.
2391+
$payment_method_type = WC_Stripe_UPE_Payment_Method_CC::STRIPE_ID;
2392+
$payment_method_settings = get_option( "woocommerce_stripe_{$payment_method_type}_settings", [] );
2393+
$payment_method_settings['title'] = 'Custom Card Title';
2394+
update_option( "woocommerce_stripe_{$payment_method_type}_settings", $payment_method_settings );
2395+
2396+
$this->mock_gateway->set_payment_method_title_for_order( $order, $payment_method_type );
2397+
2398+
$this->assertEquals( 'Custom Card Title', $order->get_payment_method_title() );
2399+
2400+
// SEPA
2401+
// Set a custom title.
2402+
$payment_method_type = WC_Stripe_UPE_Payment_Method_Sepa::STRIPE_ID;
2403+
$payment_method_settings = get_option( "woocommerce_stripe_{$payment_method_type}_settings", [] );
2404+
$payment_method_settings['title'] = 'Custom SEPA Title';
2405+
update_option( "woocommerce_stripe_{$payment_method_type}_settings", $payment_method_settings );
2406+
2407+
$this->mock_gateway->set_payment_method_title_for_order( $order, $payment_method_type );
2408+
2409+
$this->assertEquals( 'Custom SEPA Title', $order->get_payment_method_title() );
2410+
}
23822411
}

0 commit comments

Comments
 (0)