|
7 | 7 | use NewfoldLabs\WP\Module\Onboarding\Data\Config;
|
8 | 8 | use NewfoldLabs\WP\Module\Onboarding\Data\Flows\Flows;
|
9 | 9 | use NewfoldLabs\WP\Module\Onboarding\Data\Services\SiteGenService;
|
| 10 | +use NewfoldLabs\WP\Module\Onboarding\Services\ReduxStateService; |
10 | 11 |
|
11 | 12 | /**
|
12 | 13 | * Tracks the Status of Onboarding.
|
@@ -47,6 +48,10 @@ public static function handle_abandoned(): void {
|
47 | 48 | public static function handle_completed(): void {
|
48 | 49 | if ( 'started' === get_option( Options::get_option_name( 'status' ) ) ) {
|
49 | 50 | update_option( Options::get_option_name( 'status' ), 'completed' );
|
| 51 | + |
| 52 | + // Save onboarding site information to database option. |
| 53 | + self::save_site_info(); |
| 54 | + |
50 | 55 | /**
|
51 | 56 | * We're disabling the restart onboarding feature for now.
|
52 | 57 | */
|
@@ -188,4 +193,21 @@ public static function track(): void {
|
188 | 193 | // Handle abandoned event.
|
189 | 194 | self::handle_abandoned();
|
190 | 195 | }
|
| 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 | + } |
191 | 213 | }
|
0 commit comments