Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Onboarding task
Browse files Browse the repository at this point in the history
  • Loading branch information
mikejolley committed Oct 16, 2023
1 parent 42735bf commit 0314cea
Show file tree
Hide file tree
Showing 4 changed files with 126 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export function IncompatibleExtensionsNotice( {
sprintf(
// translators: %s is the name of the parent block.
__(
'The following extensions may be incompatible with the block-based %s. <a>Learn more</a>',
'Some extensions do not yet support the new %s and may impact the shopper experience. <a>Learn more</a>',
'woo-gutenberg-products-block'
),
blockLabel
Expand All @@ -81,7 +81,7 @@ export function IncompatibleExtensionsNotice( {
sprintf(
// translators: %1$s is the name of the extension, %2$s is the name of the parent block.
__(
'<strong>%1$s</strong> may be incompatible with the block-based %2$s. <a>Learn more</a>',
'<strong>%1$s</strong> does not yet support the new %2$s and may impact the shopper experience. <a>Learn more</a>',
'woo-gutenberg-products-block'
),
Object.values( incompatiblePaymentMethods )[ 0 ],
Expand Down
9 changes: 9 additions & 0 deletions src/Domain/Bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
use Automattic\WooCommerce\Blocks\Shipping\ShippingController;
use Automattic\WooCommerce\Blocks\Templates\SingleProductTemplateCompatibility;
use Automattic\WooCommerce\Blocks\Templates\ArchiveProductTemplatesCompatibility;
use Automattic\WooCommerce\Blocks\Domain\Services\OnboardingTasks\TasksController;

/**
* Takes care of bootstrapping the plugin.
Expand Down Expand Up @@ -129,6 +130,7 @@ function() {
$this->container->get( DraftOrders::class )->init();
$this->container->get( CreateAccount::class )->init();
$this->container->get( ShippingController::class )->init();
$this->container->get( TasksController::class )->init();

// Load assets in admin and on the frontend.
if ( ! $is_rest ) {
Expand All @@ -137,6 +139,7 @@ function() {
$this->container->get( AssetsController::class );
$this->container->get( Installer::class )->init();
$this->container->get( GoogleAnalytics::class )->init();

}

// Load assets unless this is a request specifically for the store API.
Expand Down Expand Up @@ -431,6 +434,12 @@ function ( $container ) {
return new ShippingController( $asset_api, $asset_data_registry );
}
);
$this->container->register(
TasksController::class,
function() {
return new TasksController();
}
);
}

/**
Expand Down
86 changes: 86 additions & 0 deletions src/Domain/Services/OnboardingTasks/ReviewCheckoutTask.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
<?php

namespace Automattic\WooCommerce\Blocks\Domain\Services\OnboardingTasks;

use Automattic\WooCommerce\Admin\Features\OnboardingTasks\Task;

/**
* Review the cart/checkout Task
*/
class ReviewCheckoutTask extends Task {
/**
* ID.
*
* @return string
*/
public function get_id() {
return 'review-checkout-experience';
}

/**
* Title.
*
* @return string
*/
public function get_title() {
return __( 'Review the shopper checkout experience', 'woo-gutenberg-products-block' );
}

/**
* Content.
*
* @return string
*/
public function get_content() {
return __( 'Make sure cart and checkout flows are configured correctly for your shoppers.', 'woo-gutenberg-products-block' );
}

/**
* Time.
*
* @return string
*/
public function get_time() {
return '';
}

/**
* Check if a task is dismissable.
*
* @return bool
*/
public function is_dismissable() {
return false;
}

/**
* Task completion.
*
* @return bool
*/
public function is_complete() {
return false;
}

/**
* Task visibility.
*
* @return bool
*/
public function can_view() {
$checkout_page_id = wc_get_page_id( 'checkout' );

return $checkout_page_id > 0;
}

/**
* Action URL.
*
* @return string
*/
public function get_action_url() {
$checkout_page_id = wc_get_page_id( 'checkout' );

return admin_url( 'site-editor.php?postType=page&postId=' . $checkout_page_id );
}
}
29 changes: 29 additions & 0 deletions src/Domain/Services/OnboardingTasks/TasksController.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?php

namespace Automattic\WooCommerce\Blocks\Domain\Services\OnboardingTasks;

use Automattic\WooCommerce\Blocks\Domain\Services\OnboardingTasks\ReviewCheckoutTask;
use Automattic\WooCommerce\Admin\Features\OnboardingTasks\TaskLists;

/**
* Onboarding Tasks Controller
*/
class TasksController {

/**
* Init tasks.
*/
public function init() {
add_action( 'init', [ $this, 'register_tasks' ] );
}

/**
* Register tasks.
*/
public function register_tasks() {
TaskLists::add_task(
'extended',
new ReviewCheckoutTask()
);
}
}

0 comments on commit 0314cea

Please sign in to comment.