Skip to content

Commit ebcbcbc

Browse files
committed
using reduxstate to fetch data
1 parent 02f5357 commit ebcbcbc

File tree

3 files changed

+22
-64
lines changed

3 files changed

+22
-64
lines changed

includes/Services/AppService.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@
66
use NewfoldLabs\WP\Module\Onboarding\Data\Options;
77
use NewfoldLabs\WP\Module\Onboarding\Data\Services\PreviewsService;
88
use NewfoldLabs\WP\Module\Onboarding\Data\Services\SiteGenService as LegacySiteGenService;
9-
use NewfoldLabs\WP\Module\Onboarding\Services\SiteInfoService;
10-
119

1210
use function NewfoldLabs\WP\ModuleLoader\container;
1311

@@ -67,9 +65,6 @@ public function complete( string $selected_sitegen_homepage ): void {
6765
// Mark onboarding as completed.
6866
StatusService::handle_completed();
6967

70-
// Save onboarding site information for other modules to access.
71-
SiteInfoService::save_site_info();
72-
7368
// Purge all caches.
7469
container()->get( 'cachePurger' )->purge_all();
7570

includes/Services/SiteInfoService.php

Lines changed: 0 additions & 59 deletions
This file was deleted.

includes/Services/StatusService.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
use NewfoldLabs\WP\Module\Onboarding\Data\Config;
88
use NewfoldLabs\WP\Module\Onboarding\Data\Flows\Flows;
99
use NewfoldLabs\WP\Module\Onboarding\Data\Services\SiteGenService;
10+
use NewfoldLabs\WP\Module\Onboarding\Services\ReduxStateService;
1011

1112
/**
1213
* Tracks the Status of Onboarding.
@@ -47,6 +48,10 @@ public static function handle_abandoned(): void {
4748
public static function handle_completed(): void {
4849
if ( 'started' === get_option( Options::get_option_name( 'status' ) ) ) {
4950
update_option( Options::get_option_name( 'status' ), 'completed' );
51+
52+
// Save onboarding site information to database option.
53+
self::save_site_info();
54+
5055
/**
5156
* We're disabling the restart onboarding feature for now.
5257
*/
@@ -188,4 +193,21 @@ public static function track(): void {
188193
// Handle abandoned event.
189194
self::handle_abandoned();
190195
}
196+
197+
/**
198+
* Save onboarding site information to database option for other modules to access.
199+
*
200+
* @return void
201+
*/
202+
public static function save_site_info(): void {
203+
$site_info = array();
204+
205+
// Get experience level and site type from ReduxStateService
206+
$data = ReduxStateService::get( 'input' );
207+
$site_info['experience_level'] = $data['experienceLevel'] ?? 3;
208+
$site_info['site_type'] = $data['siteType'] ?? 'business';
209+
210+
// Save to database option
211+
update_option( Options::get_option_name( 'site_info' ), $site_info );
212+
}
191213
}

0 commit comments

Comments
 (0)