Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add enablement query param #243

Merged
merged 1 commit into from
May 31, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions includes/Data/Options.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ final class Options {
protected static $options = array(
'redirect' => 'redirect',
'redirect_param' => 'redirect_param',
'activate' => 'activate',
'activate_param' => 'activate_param',
'coming_soon' => 'nfd_coming_soon',
'brand' => 'mm_brand',
'close_comments_for_old_posts' => 'close_comments_for_old_posts',
Expand Down
24 changes: 17 additions & 7 deletions includes/ModuleController.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,11 @@ public static function init() {
* Enable/Disable Onboarding based on certain checks.
*/
public static function module_switcher() {

$module_name = 'onboarding';

// Set brand context for the module.
Brands::set_current_brand( container() );
$customer_data = Data::customer_data();

$enable_onboarding = self::verify_onboarding_criteria( $customer_data );
$enable_onboarding = self::verify_onboarding_criteria();

// Check if he is a Non-Ecommerce Customer and Disable Redirect and Module
if ( ! $enable_onboarding ) {
Expand All @@ -61,12 +58,25 @@ public static function module_switcher() {
/**
* Verify all the necessary criteria to enable Onboarding for the site.
*
* @param array $customer_data The brand customer data.
* @return boolean
*/
public static function verify_onboarding_criteria( $customer_data ) {
$brand_enabled_flows = Flows::get_flows();
public static function verify_onboarding_criteria() {
// Check if nfd_module_onboarding_activate query param was passed previously.
$activate_transient_name = Options::get_option_name( 'activate_param' );
if ( '1' === get_transient( $activate_transient_name ) ) {
return true;
}

// If the transient does not exist, check if nfd_module_onboarding_activate query param has been passed.
$activate_param_name = Options::get_option_name( 'activate' );
if ( isset( $_GET[ $activate_param_name ] ) && Permissions::is_authorized_admin() ) {
// Set a 30 day transient that reflects this parameter being passed.
set_transient( $activate_transient_name, '1', 2592000 );
return true;
}

$customer_data = Data::customer_data();
$brand_enabled_flows = Flows::get_flows();
foreach ( $brand_enabled_flows as $flow => $enabled ) {
if ( ! $enabled ) {
continue;
Expand Down