Merge pull request #3074 from woocommerce/PCP-4195-things-to-do-reset-the-dismissed-items-on-disconnect

Things To Do: Reset todos on disconnect (4195)
This commit is contained in:
Emili Castells 2025-02-07 17:20:02 +01:00 committed by GitHub
commit 592e9cb50c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 16 additions and 0 deletions

View file

@ -79,6 +79,14 @@ class TodosModel extends AbstractDataModel {
$this->save();
}
/**
* Resets completed onclick todos.
*/
public function reset_completed_onclick_todos(): void {
$this->data['completedOnClickTodos'] = array();
$this->save();
}
/**
* Gets current todos data including dismissed and completed states.
*

View file

@ -23,6 +23,7 @@ use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\P24Gateway;
use WooCommerce\PayPalCommerce\LocalAlternativePaymentMethods\TrustlyGateway;
use WooCommerce\PayPalCommerce\Settings\Ajax\SwitchSettingsUiEndpoint;
use WooCommerce\PayPalCommerce\Settings\Data\OnboardingProfile;
use WooCommerce\PayPalCommerce\Settings\Data\TodosModel;
use WooCommerce\PayPalCommerce\Settings\Endpoint\RestEndpoint;
use WooCommerce\PayPalCommerce\Settings\Handler\ConnectionListener;
use WooCommerce\PayPalCommerce\Vendor\Inpsyde\Modularity\Module\ExecutableModule;
@ -263,12 +264,19 @@ class SettingsModule implements ServiceModule, ExecutableModule {
add_action(
'woocommerce_paypal_payments_merchant_disconnected',
static function () use ( $container ) : void {
// Reset onboarding profile.
$onboarding_profile = $container->get( 'settings.data.onboarding' );
assert( $onboarding_profile instanceof OnboardingProfile );
$onboarding_profile->set_completed( false );
$onboarding_profile->set_step( 0 );
$onboarding_profile->save();
// Reset dismissed and completed on click todos.
$todos = $container->get( 'settings.data.todos' );
assert( $todos instanceof TodosModel );
$todos->reset_dismissed_todos();
$todos->reset_completed_onclick_todos();
}
);