@@ -210,7 +210,6 @@ public function add_payments_menu_for_treatment() {
210
210
);
211
211
212
212
$ this ->add_menu_notification_badge ();
213
- $ this ->add_update_business_details_task ();
214
213
}
215
214
216
215
/**
@@ -419,7 +418,6 @@ public function add_payments_menu() {
419
418
);
420
419
421
420
$ this ->add_menu_notification_badge ();
422
- $ this ->add_update_business_details_task ();
423
421
$ this ->add_disputes_notification_badge ();
424
422
if ( \WC_Payments_Features::is_auth_and_capture_enabled () && $ this ->wcpay_gateway ->get_option ( 'manual_capture ' ) === 'yes ' ) {
425
423
$ this ->add_transactions_notification_badge ();
@@ -478,6 +476,8 @@ public function register_payments_scripts() {
478
476
];
479
477
}
480
478
479
+ $ account_status_data = $ this ->account ->get_account_status_data ();
480
+
481
481
$ wcpay_settings = [
482
482
'connectUrl ' => WC_Payments_Account::get_connect_url (),
483
483
'connect ' => [
@@ -496,11 +496,11 @@ public function register_payments_scripts() {
496
496
'fraudServices ' => $ this ->account ->get_fraud_services_config (),
497
497
'isJetpackConnected ' => $ this ->payments_api_client ->is_server_connected (),
498
498
'isJetpackIdcActive ' => Jetpack_Identity_Crisis::has_identity_crisis (),
499
- 'accountStatus ' => $ this -> account -> get_account_status_data () ,
499
+ 'accountStatus ' => $ account_status_data ,
500
500
'accountFees ' => $ this ->account ->get_fees (),
501
501
'accountLoans ' => $ this ->account ->get_capital (),
502
502
'accountEmail ' => $ this ->account ->get_account_email (),
503
- 'showUpdateDetailsTask ' => get_option ( ' wcpay_show_update_business_details_task ' , ' no ' ),
503
+ 'showUpdateDetailsTask ' => $ this -> get_should_show_update_business_details_task ( $ account_status_data ),
504
504
'wpcomReconnectUrl ' => $ this ->payments_api_client ->is_server_connected () && ! $ this ->payments_api_client ->has_server_connection_owner () ? WC_Payments_Account::get_wpcom_reconnect_url () : null ,
505
505
'additionalMethodsSetup ' => [
506
506
'isUpeEnabled ' => WC_Payments_Features::is_upe_enabled (),
@@ -809,21 +809,24 @@ public function add_menu_notification_badge() {
809
809
}
810
810
811
811
/**
812
- * Attempts to add a setup task to remind the user to update
813
- * their business details when the account is facing restriction.
812
+ * Check whether a setup task needs to be displayed prompting the user to update
813
+ * their business details.
814
+ *
815
+ * @param array $account_status_data An array containing the account status data.
816
+ *
817
+ * @return bool True if we should show the task, false otherwise.
814
818
*/
815
- public function add_update_business_details_task () {
816
- if ( 'yes ' === get_option ( 'wcpay_show_update_business_details_task ' , 'no ' ) ) {
817
- return ;
819
+ public function get_should_show_update_business_details_task ( array $ account_status_data ) {
820
+ $ status = $ account_status_data ['status ' ] ?? '' ;
821
+ $ current_deadline = $ account_status_data ['currentDeadline ' ] ?? false ;
822
+ $ past_due = $ account_status_data ['pastDue ' ] ?? false ;
823
+
824
+ // If the account is restricted_soon, but there's no current deadline, no action is needed.
825
+ if ( ( 'restricted_soon ' === $ status && $ current_deadline ) || ( 'restricted ' === $ status && $ past_due ) ) {
826
+ return true ;
818
827
}
819
828
820
- $ account = $ this ->account ->get_account_status_data ();
821
- $ status = $ account ['status ' ] ?? '' ;
822
- $ past_due = $ account ['has_overdue_requirements ' ] ?? false ;
823
-
824
- if ( 'restricted_soon ' === $ status || ( 'restricted ' === $ status && $ past_due ) ) {
825
- update_option ( 'wcpay_show_update_business_details_task ' , 'yes ' );
826
- }
829
+ return false ;
827
830
}
828
831
829
832
/**
0 commit comments