Added new notification to ask about starting a dropshipping business. (https://github.com/woocommerce/woocommerce-admin/pull/4455)

* Added new notification to ask about starting a dropshipping business.

This commit adds a new notification to ask the client if they are considering starting a dropshipping business.

* Bugfix: corrected some problems in this note's logic

This commit adds a new validation for onboarding_profile, it removes an incorrect validation and changes the action's name

Co-authored-by: Fernando Marichal <contacto@fernandomarichal.com>
This commit is contained in:
Fernando 2020-06-10 10:32:12 -03:00 committed by GitHub
parent e19d3cfbd4
commit d68c80ed15
2 changed files with 78 additions and 0 deletions

View File

@ -20,6 +20,7 @@ use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Personalize_Store;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_EU_VAT_Number;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_WooCommerce_Payments;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Marketing;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Start_Dropshipping_Business;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_WooCommerce_Subscriptions;
use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Migrate_From_Shopify;
use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\DataSourcePoller;
@ -79,6 +80,7 @@ class Events {
WC_Admin_Notes_EU_VAT_Number::possibly_add_note();
WC_Admin_Notes_Marketing::possibly_add_note();
WC_Admin_Notes_Giving_Feedback_Notes::possibly_add_note();
WC_Admin_Notes_Start_Dropshipping_Business::possibly_add_note();
WC_Admin_Notes_WooCommerce_Subscriptions::possibly_add_note();
WC_Admin_Notes_Migrate_From_Shopify::possibly_add_note();

View File

@ -0,0 +1,76 @@
<?php
/**
* WooCommerce Admin: Starting a dropshipping business.
*
* Adds a note to ask the client if they are considering starting a dropshipping business.
*
* @package WooCommerce Admin
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* WC_Admin_Notes_Start_Dropshipping_Business.
*/
class WC_Admin_Notes_Start_Dropshipping_Business {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-start-dropshipping-business';
/**
* Get the note.
*/
public static function get_note() {
// We want to show the note after one day.
if ( ! self::wc_admin_active_for( DAY_IN_SECONDS ) ) {
return;
}
$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( __( 'Are you considering starting a dropshipping business?', 'woocommerce-admin' ) );
$note->set_content( __( 'The ability to add inventory without having to deal with production, stocking, or fulfilling orders may seem like a dream. But is dropshipping worth it? Lets explore some of the advantages and disadvantages to help you make the best decision for your business.', '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(
'dropshipping-business',
__( 'Learn more', 'woocommerce-admin' ),
'https://woocommerce.com/posts/is-dropshipping-worth-it-pros-cons/?utm_source=inbox',
WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED,
true
);
return $note;
}
}