Skip to content

Commit 8b525d4

Browse files
rtioclaude
andauthored
fix: correct option type for duplicate payment method dismissed notices (#11336)
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 61d766f commit 8b525d4

File tree

4 files changed

+40
-15
lines changed

4 files changed

+40
-15
lines changed
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Fixed duplicate payment method dismissed notices option type from bool to array, allowing notice dismissals to persist across page refreshes.

includes/admin/class-wc-rest-payments-settings-option-controller.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class WC_REST_Payments_Settings_Option_Controller extends WC_Payments_REST_Contr
2727
'wcpay_onboarding_eligibility_modal_dismissed' => 'bool',
2828
'wcpay_connection_success_modal_dismissed' => 'bool',
2929
'wcpay_next_deposit_notice_dismissed' => 'bool',
30-
'wcpay_duplicate_payment_method_notices_dismissed' => 'bool',
30+
'wcpay_duplicate_payment_method_notices_dismissed' => 'array',
3131
'wcpay_instant_deposit_notice_dismissed' => 'bool',
3232
'wcpay_exit_survey_last_shown' => 'string',
3333
];

tests/unit/admin/test-class-wc-rest-payments-settings-option-controller.php

Lines changed: 19 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,16 @@ public function test_validate_option_name( string $option, bool $expected_result
8383
*/
8484
public function provider_valid_values(): array {
8585
return [
86-
'bool option with true' => [ 'wcpay_multi_currency_setup_completed', true ],
87-
'bool option with false' => [ 'wcpay_multi_currency_setup_completed', false ],
88-
'array option with empty array' => [ 'woocommerce_dismissed_todo_tasks', [] ],
89-
'array option with array' => [ 'woocommerce_dismissed_todo_tasks', [ 'key' => 'value' ] ],
90-
'array option with nested array' => [ 'woocommerce_dismissed_todo_tasks', [ 'key' => [ 'nested' => 'value' ] ] ],
91-
'string option with string' => [ 'wcpay_exit_survey_last_shown', '2026-01-09T09:23:30.444Z' ],
86+
'bool option with true' => [ 'wcpay_multi_currency_setup_completed', true ],
87+
'bool option with false' => [ 'wcpay_multi_currency_setup_completed', false ],
88+
'array option with empty array' => [ 'woocommerce_dismissed_todo_tasks', [] ],
89+
'array option with array' => [ 'woocommerce_dismissed_todo_tasks', [ 'key' => 'value' ] ],
90+
'array option with nested array' => [ 'woocommerce_dismissed_todo_tasks', [ 'key' => [ 'nested' => 'value' ] ] ],
91+
'string option with string' => [ 'wcpay_exit_survey_last_shown', '2026-01-09T09:23:30.444Z' ],
92+
'array option for dismissed duplicate notices' => [
93+
'wcpay_duplicate_payment_method_notices_dismissed',
94+
[ 'card' => [ 'woocommerce_payments', 'stripe' ] ],
95+
],
9296
];
9397
}
9498

@@ -110,14 +114,15 @@ public function test_validate_value_with_valid_values( string $option_name, $val
110114
*/
111115
public function provider_invalid_values(): array {
112116
return [
113-
'bool option with string' => [ 'wcpay_multi_currency_setup_completed', 'string' ],
114-
'bool option with array' => [ 'wcpay_multi_currency_setup_completed', [] ],
115-
'bool option with int' => [ 'wcpay_multi_currency_setup_completed', 123 ],
116-
'array option with bool' => [ 'woocommerce_dismissed_todo_tasks', true ],
117-
'array option with string' => [ 'woocommerce_dismissed_todo_tasks', 'string' ],
118-
'string option with bool' => [ 'wcpay_exit_survey_last_shown', true ],
119-
'string option with array' => [ 'wcpay_exit_survey_last_shown', [] ],
120-
'string option with int' => [ 'wcpay_exit_survey_last_shown', 123 ],
117+
'bool option with string' => [ 'wcpay_multi_currency_setup_completed', 'string' ],
118+
'bool option with array' => [ 'wcpay_multi_currency_setup_completed', [] ],
119+
'bool option with int' => [ 'wcpay_multi_currency_setup_completed', 123 ],
120+
'array option with bool' => [ 'woocommerce_dismissed_todo_tasks', true ],
121+
'array option with string' => [ 'woocommerce_dismissed_todo_tasks', 'string' ],
122+
'string option with bool' => [ 'wcpay_exit_survey_last_shown', true ],
123+
'string option with array' => [ 'wcpay_exit_survey_last_shown', [] ],
124+
'string option with int' => [ 'wcpay_exit_survey_last_shown', 123 ],
125+
'array option (dismissed notices) with bool' => [ 'wcpay_duplicate_payment_method_notices_dismissed', true ],
121126
];
122127
}
123128

tests/unit/duplicate-detection/test-class-duplicates-detection-service.php

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ public function test_two_prbs_enabled() {
116116
$this->assertEquals( 'apple_pay_google_pay', array_keys( $result )[0] );
117117
}
118118

119+
public function test_prb_detection_excludes_disabled_stripe_gateway() {
120+
// WCPay gateway enabled with PRB.
121+
$this->woopayments_gateway->id = 'woocommerce_payments';
122+
$this->woopayments_gateway->enabled = 'yes';
123+
$this->woopayments_gateway->is_payment_request_enabled_value = true;
124+
125+
// Stripe gateway disabled but with payment_request still enabled in settings.
126+
$this->gateway_from_another_plugin->id = 'stripe';
127+
$this->gateway_from_another_plugin->enabled = 'no';
128+
$this->gateway_from_another_plugin->settings = [ 'payment_request' => 'yes' ];
129+
130+
$result = $this->service->find_duplicates();
131+
132+
$this->assertEmpty( $result );
133+
}
134+
119135
public function test_duplicate_not_enabled_in_woopayments() {
120136
$this->set_duplicates( CC_Payment_Method::PAYMENT_METHOD_STRIPE_ID, 'yes', 'yes' );
121137
$this->woopayments_gateway->id = 'not_woopayments_card';

0 commit comments

Comments
 (0)