diff --git a/plugins/woocommerce-admin/client/dashboard/task-list/index.js b/plugins/woocommerce-admin/client/dashboard/task-list/index.js index 3fb3ec2a91f..cb0940a677e 100644 --- a/plugins/woocommerce-admin/client/dashboard/task-list/index.js +++ b/plugins/woocommerce-admin/client/dashboard/task-list/index.js @@ -30,6 +30,12 @@ class TaskDashboard extends Component { document.body.classList.add( 'woocommerce-task-dashboard__body' ); this.recordEvent(); + + if ( this.props.inline ) { + this.props.updateOptions( { + woocommerce_task_list_complete: true, + } ); + } } componentWillUnmount() { diff --git a/plugins/woocommerce-admin/src/Features/Onboarding.php b/plugins/woocommerce-admin/src/Features/Onboarding.php index 10b0ba734ad..36cdbee3928 100644 --- a/plugins/woocommerce-admin/src/Features/Onboarding.php +++ b/plugins/woocommerce-admin/src/Features/Onboarding.php @@ -49,14 +49,15 @@ class Onboarding { * Hook into WooCommerce. */ public function __construct() { - if ( ! is_admin() ) { - return; - } - // Include WC Admin Onboarding classes. if ( $this->should_show_tasks() ) { OnboardingTasks::get_instance(); } + + if ( ! is_admin() ) { + return; + } + // Old settings injection. // Run after Automattic\WooCommerce\Admin\Loader. add_filter( 'woocommerce_components_settings', array( $this, 'component_settings' ), 20 ); diff --git a/plugins/woocommerce-admin/src/Features/OnboardingTasks.php b/plugins/woocommerce-admin/src/Features/OnboardingTasks.php index f50e3adb712..a56a63fd7de 100644 --- a/plugins/woocommerce-admin/src/Features/OnboardingTasks.php +++ b/plugins/woocommerce-admin/src/Features/OnboardingTasks.php @@ -9,6 +9,7 @@ namespace Automattic\WooCommerce\Admin\Features; use Automattic\WooCommerce\Admin\API\Reports\Taxes\Stats\DataStore; +use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Onboarding; /** * Contains the logic for completing onboarding tasks. @@ -42,6 +43,13 @@ class OnboardingTasks { * Constructor */ public function __construct() { + // This hook needs to run when options are updated via REST. + add_action( 'add_option_woocommerce_task_list_complete', array( $this, 'add_completion_note' ), 10, 2 ); + + if ( ! is_admin() ) { + return; + } + add_action( 'admin_enqueue_scripts', array( $this, 'add_media_scripts' ) ); // Old settings injection. // Run after Onboarding. @@ -171,4 +179,16 @@ class OnboardingTasks { return $tax_supported_countries; } + + /** + * Add the task list completion note after completing all tasks. + * + * @param mixed $old_value Old value. + * @param mixed $new_value New value. + */ + public static function add_completion_note( $old_value, $new_value ) { + if ( $new_value ) { + WC_Admin_Notes_Onboarding::add_task_list_complete_note(); + } + } } diff --git a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php new file mode 100644 index 00000000000..d3c6f6f4253 --- /dev/null +++ b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Onboarding.php @@ -0,0 +1,52 @@ +get_notes_with_name( self::NOTE_NAME ); + if ( ! empty( $note_ids ) ) { + return; + } + + $note = new WC_Admin_Note(); + $note->set_title( __( 'Congratulations - your store is ready for launch!', 'woocommerce-admin' ) ); + $note->set_content( __( 'You’re ready to take your first order - may the sales roll in!', 'woocommerce-admin' ) ); + $note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); + $note->set_icon( 'notice' ); + $note->set_name( self::NOTE_NAME ); + $note->set_content_data( (object) array() ); + $note->set_source( 'woocommerce-admin' ); + $note->add_action( + 'market-store', + __( 'Market my store', 'woocommerce-admin' ), + 'https://woocommerce.com/product-category/woocommerce-extensions/marketing-extensions/' + ); + + $note->save(); + } +}