This commit is contained in:
Joshua T Flowers 2021-01-07 16:23:43 -05:00 committed by GitHub
parent 6c3f30a1de
commit 24261198ad
2 changed files with 21 additions and 28 deletions

View File

@ -42,6 +42,7 @@ use \Automattic\WooCommerce\Admin\Notes\ManageOrdersOnTheGo;
use \Automattic\WooCommerce\Admin\Notes\NavigationFeedback;
use \Automattic\WooCommerce\Admin\Notes\NavigationFeedbackFollowUp;
use \Automattic\WooCommerce\Admin\Notes\FilterByProductVariationsInReports;
use \Automattic\WooCommerce\Admin\Notes\DrawAttention;
/**
* Events Class.
@ -115,6 +116,7 @@ class Events {
NavigationFeedback::possibly_add_note();
NavigationFeedbackFollowUp::possibly_add_note();
FilterByProductVariationsInReports::possibly_add_note();
DrawAttention::possibly_add_note();
ChoosingTheme::possibly_add_note();
InsightFirstProductAndPayment::possibly_add_note();

View File

@ -30,33 +30,7 @@ class DrawAttention {
*/
public function __construct() {
// Trigger this when the onboarding options are updated.
add_filter(
'update_option_' . Onboarding::PROFILE_DATA_OPTION,
array( $this, 'check_onboarding_profile' ),
10,
3
);
}
/**
* Check to see if profiler options match before possibly adding note.
*
* @param object $old_value The old option value.
* @param object $value The new option value.
* @param string $option The name of the option.
*/
public static function check_onboarding_profile( $old_value, $value, $option ) {
// Skip adding if this store is being set up for a client.
if ( ! isset( $value['setup_client'] ) || $value['setup_client'] ) {
return;
}
// Skip adding if the merchant has no products.
if ( ! isset( $value['product_count'] ) || '0' === $value['product_count'] ) {
return;
}
self::possibly_add_note();
add_filter( 'update_option_' . Onboarding::PROFILE_DATA_OPTION, array( $this, 'possibly_add_note' ) );
}
/**
@ -65,8 +39,25 @@ class DrawAttention {
* @return Note
*/
public static function get_note() {
// We want to show the note after 3 days.
if ( ! self::wc_admin_active_for( 3 * DAY_IN_SECONDS ) ) {
return;
}
$profile_data = get_option( Onboarding::PROFILE_DATA_OPTION, array() );
// Skip adding if this store is being set up for a client.
if ( ! isset( $profile_data['setup_client'] ) || $profile_data['setup_client'] ) {
return;
}
// Skip adding if the merchant has no products.
if ( ! isset( $profile_data['product_count'] ) || '0' === $profile_data['product_count'] ) {
return;
}
$note = new Note();
$note->set_title( __( 'How to draw attention to your online store', 'woocommerce-admin' ) );
$note->set_title( __( 'Get noticed: how to draw attention to your online store', 'woocommerce-admin' ) );
$note->set_content( __( 'To get you started, here are seven ways to boost your sales and avoid getting drowned out by similar, mass-produced products competing for the same buyers.', 'woocommerce-admin' ) );
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );