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 conditional check to replace launch-site task with LYS task #1509

Merged
merged 5 commits into from
Sep 6, 2024
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
46 changes: 16 additions & 30 deletions includes/class-wc-calypso-bridge-setup-tasks.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ private function __construct() {
// All plans.
add_action( 'load-woocommerce_page_wc-settings', array( $this, 'redirect_store_details_onboarding' ) );
add_action( 'wp_ajax_launch_store', array( $this, 'handle_ajax_launch_endpoint' ) );
add_action( 'init', array( $this, 'add_tasks' ) );
add_filter( 'woocommerce_admin_experimental_onboarding_tasklists', [ $this, 'replace_tasks' ] );
add_filter( 'get_user_metadata', array( $this, 'override_user_meta_field' ), 10, 4 );
}
Expand Down Expand Up @@ -86,14 +85,9 @@ public function handle_ajax_launch_endpoint() {
}

/**
* Add Setup Tasks.
* Add and replace setup tasks.
*/
public function add_tasks() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Entirely merged this function into replace_tasks


if ( ! class_exists( '\Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists' ) ) {
return;
}

public function replace_tasks( $lists ) {
/**
* `ecommerce_custom_setup_tasks_enabled` filter.
*
Expand All @@ -104,27 +98,7 @@ public function add_tasks() {
* @param bool $status_enabled
* @return bool
*/
if ( ! (bool) apply_filters( 'ecommerce_custom_setup_tasks_enabled', true ) ) {
return;
}

$tl = \Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists::instance();
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-add-domain.php';
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-launch-site.php';

$list = $tl::get_lists_by_ids( array( 'setup' ) );
$list = array_pop( $list );

$add_domain_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\AddDomain( $list );
$launch_site_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\LaunchSite( $list );
$tl::add_task( 'setup', $add_domain_task );
$tl::add_task( 'setup', $launch_site_task );
}

/**
* Replace setup tasks.
*/
public function replace_tasks( $lists ) {
$ecommerce_custom_setup_tasks_enabled = (bool) apply_filters( 'ecommerce_custom_setup_tasks_enabled', true );
if ( isset( $lists['setup'] ) ) {
// Default product task index.
$product_task_index = 2;
Expand All @@ -142,7 +116,19 @@ public function replace_tasks( $lists ) {
unset( $lists['setup']->tasks[$index] );
break;
case 'launch-your-store':
if ( wc_calypso_bridge_is_trial_plan() ) {
if ( $ecommerce_custom_setup_tasks_enabled ) {
// Append add domain task before launch your store task.
require_once __DIR__ . '/tasks/class-wc-calypso-task-add-domain.php';
$add_domain_task = array( new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\AddDomain( $lists['setup'] ) );
array_splice( $lists['setup']->tasks, $index, 0, $add_domain_task );

// Replace launch your store task with launch site task.
if ( ! Features::is_enabled( 'launch-your-store' ) && ! wc_calypso_bridge_is_trial_plan() ) {
require_once WC_CALYPSO_BRIDGE_PLUGIN_PATH . '/includes/tasks/class-wc-calypso-task-launch-site.php';
$launch_site_task = new \Automattic\WooCommerce\Admin\Features\OnboardingTasks\Tasks\LaunchSite( $lists['setup'] );
$lists['setup']->tasks[$index + 1] = $launch_site_task;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$index + 1 because index was bumped up since we added domain task above

}
} else if ( wc_calypso_bridge_is_trial_plan() ) {
// Don't show launch your store task for trial sites.
unset( $lists['setup']->tasks[$index] );
}
Expand Down
1 change: 1 addition & 0 deletions readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ This section describes how to install the plugin and get it working.
* Add sync coming soon status from LYS to WPCOM #1503
* Refactor LYS to use unidirectional data flow #1506
* Disable launch your store on trial sites #1507
* Add conditional check to replace launch-site task with LYS task #1509

= 2.5.5 =
* Add a new class to customize for Stripe from Partner Aware Onboarding #1492
Expand Down
Loading