Added new notification to choose a niche (https://github.com/woocommerce/woocommerce-admin/pull/4441)
* Added new notification to choose a niche This commit adds a new notification to choose a niche # Conflicts: # src/Events.php * Bugfix: removed wrong validation * Added validation for onboarding_profile This commits adds a validation to confirm that the onboarding_profile is set. Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
This commit is contained in:
parent
1a98cd0dbc
commit
0fc1ec29fb
|
@ -10,6 +10,7 @@ namespace Automattic\WooCommerce\Admin;
|
|||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Choose_Niche;
|
||||
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Giving_Feedback_Notes;
|
||||
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Mobile_App;
|
||||
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_New_Sales_Record;
|
||||
|
@ -90,6 +91,7 @@ class Events {
|
|||
WC_Admin_Notes_Learn_More_About_Product_Settings::possibly_add_note();
|
||||
WC_Admin_Notes_Online_Clothing_Store::possibly_add_note();
|
||||
WC_Admin_Notes_First_Product::possibly_add_note();
|
||||
WC_Admin_Notes_Choose_Niche::possibly_add_note();
|
||||
WC_Admin_Notes_Real_Time_Order_Alerts::possibly_add_note();
|
||||
|
||||
if ( Loader::is_feature_enabled( 'remote-inbox-notifications' ) ) {
|
||||
|
|
|
@ -0,0 +1,70 @@
|
|||
<?php
|
||||
/**
|
||||
* WooCommerce Admin: Choose a niche note.
|
||||
*
|
||||
* Adds a note to show the client how to choose a niche for their store.
|
||||
*
|
||||
* @package WooCommerce Admin
|
||||
*/
|
||||
|
||||
namespace Automattic\WooCommerce\Admin\Notes;
|
||||
|
||||
defined( 'ABSPATH' ) || exit;
|
||||
|
||||
/**
|
||||
* WC_Admin_Notes_Choose_Niche.
|
||||
*/
|
||||
class WC_Admin_Notes_Choose_Niche {
|
||||
/**
|
||||
* Note traits.
|
||||
*/
|
||||
use NoteTraits;
|
||||
|
||||
/**
|
||||
* Name of the note for use in the database.
|
||||
*/
|
||||
const NOTE_NAME = 'wc-admin-choose-niche';
|
||||
|
||||
/**
|
||||
* Get the note.
|
||||
*/
|
||||
public static function get_note() {
|
||||
$onboarding_profile = get_option( 'woocommerce_onboarding_profile', array() );
|
||||
|
||||
// Confirm that $onboarding_profile is set.
|
||||
if ( empty( $onboarding_profile ) ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure that the person who filled out the OBW was not setting up the store for their customer/client.
|
||||
if ( $onboarding_profile['setup_client'] ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to show the notification when product number is 0 or the revenue is 'none' or 'up to 2500'.
|
||||
if (
|
||||
0 !== (int) $onboarding_profile['product_count'] &&
|
||||
'none' !== $onboarding_profile['revenue'] &&
|
||||
'up-to-2500' !== $onboarding_profile['revenue']
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
$note = new WC_Admin_Note();
|
||||
$note->set_title( __( 'How to choose a niche for your online store', 'woocommerce-admin' ) );
|
||||
$note->set_content( __( 'Your niche defines the products and services you develop. It directs your marketing. It focuses your attention on specific problems facing your customers. It differentiates you from the competition. Learn more about the five guiding principles to define your niche.', 'woocommerce-admin' ) );
|
||||
$note->set_type( WC_Admin_Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
|
||||
$note->set_icon( 'info' );
|
||||
$note->set_name( self::NOTE_NAME );
|
||||
$note->set_content_data( (object) array() );
|
||||
$note->set_source( 'woocommerce-admin' );
|
||||
$note->add_action(
|
||||
'choose-niche',
|
||||
__( 'Learn more', 'woocommerce-admin' ),
|
||||
'https://woocommerce.com/posts/how-to-choose-a-niche-online-business/?utm_source=inbox',
|
||||
WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED,
|
||||
true
|
||||
);
|
||||
return $note;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue