* Remove Marketing note

* Remove DrawAttention note

Remove DrawAttention note

* Remove NeedSomeInspiration note

* Remove ChooseNiche note

* Remove StartDropshippingBusiness note

* Remove FilterByProductVariationsInReports note

* Remove LearnMoreAboutVariableProducts note

* Remove GettingStartedInEcommerceWebinar note

* Remove deprecated note tests

* Add changelogs

Update changelogs

* Remove navigation feedback notes (https://github.com/woocommerce/woocommerce-admin/pull/8055)

* Remove navigation feedback note

issue woocommerce/woocommerce-admin#8043

* Add changelogs
This commit is contained in:
Chi-Hsuan Huang 2021-12-22 13:11:10 +08:00 committed by GitHub
parent 0ef8959a22
commit a43bcaca0f
18 changed files with 18 additions and 1080 deletions

View File

@ -0,0 +1,4 @@
Significance: minor
Type: Dev
Remove navigation feedback note. #8055

View File

@ -0,0 +1,4 @@
Significance: minor
Type: Dev
Remove low performing inbox notes. #8054

View File

@ -10,7 +10,6 @@ defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\Features\Features;
use \Automattic\WooCommerce\Admin\Notes\AddingAndManangingProducts;
use \Automattic\WooCommerce\Admin\Notes\ChooseNiche;
use \Automattic\WooCommerce\Admin\Notes\ChoosingTheme;
use \Automattic\WooCommerce\Admin\Notes\CustomizingProductCatalog;
use Automattic\WooCommerce\Admin\Notes\FirstDownlaodableProduct;
@ -23,9 +22,7 @@ use \Automattic\WooCommerce\Admin\Notes\OnboardingPayments;
use \Automattic\WooCommerce\Admin\Notes\PersonalizeStore;
use \Automattic\WooCommerce\Admin\Notes\EUVATNumber;
use \Automattic\WooCommerce\Admin\Notes\WooCommercePayments;
use \Automattic\WooCommerce\Admin\Notes\Marketing;
use \Automattic\WooCommerce\Admin\Notes\MarketingJetpack;
use \Automattic\WooCommerce\Admin\Notes\StartDropshippingBusiness;
use \Automattic\WooCommerce\Admin\Notes\WooCommerceSubscriptions;
use \Automattic\WooCommerce\Admin\Notes\MigrateFromShopify;
use \Automattic\WooCommerce\Admin\Notes\LaunchChecklist;
@ -34,7 +31,6 @@ use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\DataSourcePoller;
use \Automattic\WooCommerce\Admin\RemoteInboxNotifications\RemoteInboxNotificationsEngine;
use \Automattic\WooCommerce\Admin\Notes\MerchantEmailNotifications\MerchantEmailNotifications;
use \Automattic\WooCommerce\Admin\Notes\InsightFirstSale;
use \Automattic\WooCommerce\Admin\Notes\NeedSomeInspiration;
use \Automattic\WooCommerce\Admin\Notes\OnlineClothingStore;
use \Automattic\WooCommerce\Admin\Notes\FirstProduct;
use \Automattic\WooCommerce\Admin\Notes\CustomizeStoreWithBlocks;
@ -42,12 +38,7 @@ use \Automattic\WooCommerce\Admin\Notes\TestCheckout;
use \Automattic\WooCommerce\Admin\Notes\EditProductsOnTheMove;
use \Automattic\WooCommerce\Admin\Notes\PerformanceOnMobile;
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\AddFirstProduct;
use \Automattic\WooCommerce\Admin\Notes\DrawAttention;
use \Automattic\WooCommerce\Admin\Notes\GettingStartedInEcommerceWebinar;
use \Automattic\WooCommerce\Admin\Notes\NavigationNudge;
use Automattic\WooCommerce\Admin\Schedulers\MailchimpScheduler;
use \Automattic\WooCommerce\Admin\Notes\CompleteStoreDetails;
@ -125,33 +116,24 @@ class Events {
PersonalizeStore::possibly_add_note();
WooCommercePayments::possibly_add_note();
EUVATNumber::possibly_add_note();
Marketing::possibly_add_note();
MarketingJetpack::possibly_add_note();
StartDropshippingBusiness::possibly_add_note();
WooCommerceSubscriptions::possibly_add_note();
MigrateFromShopify::possibly_add_note();
InsightFirstSale::possibly_add_note();
LaunchChecklist::possibly_add_note();
NeedSomeInspiration::possibly_add_note();
OnlineClothingStore::possibly_add_note();
FirstProduct::possibly_add_note();
ChooseNiche::possibly_add_note();
RealTimeOrderAlerts::possibly_add_note();
CustomizeStoreWithBlocks::possibly_add_note();
TestCheckout::possibly_add_note();
EditProductsOnTheMove::possibly_add_note();
PerformanceOnMobile::possibly_add_note();
ManageOrdersOnTheGo::possibly_add_note();
NavigationFeedback::possibly_add_note();
NavigationFeedbackFollowUp::possibly_add_note();
FilterByProductVariationsInReports::possibly_add_note();
DrawAttention::possibly_add_note();
ChoosingTheme::possibly_add_note();
InsightFirstProductAndPayment::possibly_add_note();
AddFirstProduct::possibly_add_note();
AddingAndManangingProducts::possibly_add_note();
CustomizingProductCatalog::possibly_add_note();
GettingStartedInEcommerceWebinar::possibly_add_note();
FirstDownlaodableProduct::possibly_add_note();
NavigationNudge::possibly_add_note();
CompleteStoreDetails::possibly_add_note();
@ -163,8 +145,6 @@ class Events {
*/
protected function possibly_delete_notes() {
NavigationNudge::delete_if_not_applicable();
NavigationFeedback::delete_if_not_applicable();
NavigationFeedbackFollowUp::delete_if_not_applicable();
SetUpAdditionalPaymentTypes::delete_if_not_applicable();
}

View File

@ -7,14 +7,12 @@ namespace Automattic\WooCommerce\Admin;
defined( 'ABSPATH' ) || exit;
use \Automattic\WooCommerce\Admin\Notes\LearnMoreAboutVariableProducts;
use \Automattic\WooCommerce\Admin\Notes\Notes;
use \Automattic\WooCommerce\Admin\Notes\OrderMilestones;
use \Automattic\WooCommerce\Admin\Notes\WooSubscriptionsNotes;
use \Automattic\WooCommerce\Admin\Notes\TrackingOptIn;
use \Automattic\WooCommerce\Admin\Notes\WooCommercePayments;
use \Automattic\WooCommerce\Admin\Notes\InstallJPAndWCSPlugins;
use \Automattic\WooCommerce\Admin\Notes\DrawAttention;
use \Automattic\WooCommerce\Admin\Notes\SetUpAdditionalPaymentTypes;
use \Automattic\WooCommerce\Admin\Notes\TestCheckout;
use \Automattic\WooCommerce\Admin\Notes\SellingOnlineCourses;
@ -188,11 +186,9 @@ class FeaturePlugin {
new TrackingOptIn();
new WooCommercePayments();
new InstallJPAndWCSPlugins();
new DrawAttention();
new SetUpAdditionalPaymentTypes();
new TestCheckout();
new SellingOnlineCourses();
new LearnMoreAboutVariableProducts();
new WelcomeToWooCommerceForStoreUsers();
new ManageStoreActivityFromHomeScreen();
new NavigationNudge();

View File

@ -543,6 +543,16 @@ class Install {
'wc-admin-home-screen-feedback',
'wc-admin-effortless-payments-by-mollie',
'wc-admin-google-ads-and-marketing',
'wc-admin-marketing-intro',
'wc-admin-draw-attention',
'wc-admin-need-some-inspiration',
'wc-admin-choose-niche',
'wc-admin-start-dropshipping-business',
'wc-admin-filter-by-product-variations-in-reports',
'wc-admin-learn-more-about-variable-products',
'wc-admin-getting-started-ecommerce-webinar',
'wc-admin-navigation-feedback',
'wc-admin-navigation-feedback-follow-up',
);
$additional_obsolete_notes_names = apply_filters(

View File

@ -1,82 +0,0 @@
<?php
/**
* WooCommerce Admin: Choose a niche note.
*
* Adds a note to show the client how to choose a niche for their store.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Choose_Niche.
*/
class ChooseNiche {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-choose-niche';
/**
* Get the note.
*
* @return 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 (
! isset( $onboarding_profile['setup_client'] ) ||
$onboarding_profile['setup_client']
) {
return;
}
// Make sure that the product count is set in the onboarding profile.
if ( ! isset( $onboarding_profile['product_count'] ) ) {
return;
}
// Make sure that the revenue is set in the onboarding profile.
if ( ! isset( $onboarding_profile['revenue'] ) ) {
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 Note();
$note->set_title( __( 'Finding an audience for your business', 'woocommerce-admin' ) );
$note->set_content( __( 'Theres nothing quite like entrepreneurship! We put together a blog post series — titled From Idea to First Customer — with all the tips, resources, and tools to inspire a great idea, empower you to execute it, and lead to your very first sale.', 'woocommerce-admin' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$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/from-idea-to-first-customer/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED,
true
);
return $note;
}
}

View File

@ -76,27 +76,6 @@ class WC_Admin_Notes extends DeprecatedClassFacade {
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Choose_Niche.
*
* @deprecated since 1.7.0, use ChooseNiche
*/
class WC_Admin_Notes_Choose_Niche extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\Notes\ChooseNiche';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Coupon_Page_Moved.
*
@ -160,27 +139,6 @@ class WC_Admin_Notes_Deactivate_Plugin extends DeprecatedClassFacade {
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Draw_Attention.
*
* @deprecated since 1.7.0, use DrawAttention
*/
class WC_Admin_Notes_Draw_Attention extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\Notes\DrawAttention';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Edit_Products_On_The_Move.
*
@ -349,27 +307,6 @@ class WC_Admin_Notes_Launch_Checklist extends DeprecatedClassFacade {
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Marketing.
*
* @deprecated since 1.7.0, use Marketing
*/
class WC_Admin_Notes_Marketing extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\Notes\Marketing';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Migrate_From_Shopify.
*
@ -412,27 +349,6 @@ class WC_Admin_Notes_Mobile_App extends DeprecatedClassFacade {
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Need_Some_Inspiration.
*
* @deprecated since 1.7.0, use NeedSomeInspiration
*/
class WC_Admin_Notes_Need_Some_Inspiration extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\Notes\NeedSomeInspiration';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_New_Sales_Record.
*
@ -643,27 +559,6 @@ class WC_Admin_Notes_Set_Up_Additional_Payment_Types extends DeprecatedClassFaca
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Start_Dropshipping_Business.
*
* @deprecated since 1.7.0, use StartDropshippingBusiness
*/
class WC_Admin_Notes_Start_Dropshipping_Business extends DeprecatedClassFacade {
/**
* The name of the non-deprecated class that this facade covers.
*
* @var string
*/
protected static $facade_over_classname = 'Automattic\WooCommerce\Admin\Notes\StartDropshippingBusiness';
/**
* The version that this class was deprecated in.
*
* @var string
*/
protected static $deprecated_in_version = '1.7.0';
}
/**
* WC_Admin_Notes_Test_Checkout.
*

View File

@ -1,75 +0,0 @@
<?php
/**
* WooCommerce Admin Draw Attention note provider
*
* Adds a note to the merchant's inbox
*/
namespace Automattic\WooCommerce\Admin\Notes;
use \Automattic\WooCommerce\Admin\Features\Onboarding;
defined( 'ABSPATH' ) || exit;
/**
* Draw_Attention
*/
class DrawAttention {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-draw-attention';
/**
* Constructor.
*/
public function __construct() {
// Trigger this when the onboarding options are updated.
add_filter( 'update_option_' . Onboarding::PROFILE_DATA_OPTION, array( $this, 'possibly_add_note' ) );
}
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
// We want to show the note after 3 days.
if ( ! self::is_wc_admin_active_in_date_range( 'week-1', 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( __( '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 );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce-admin' ),
'https://woocommerce.com/posts/how-to-make-your-online-store-stand-out/?utm_source=inbox&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED,
true
);
return $note;
}
}

View File

@ -1,77 +0,0 @@
<?php
/**
* New - filter by product variations in order and product reports.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* FilterByProductVariationsInReports.
*/
class FilterByProductVariationsInReports {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-filter-by-product-variations-in-reports';
/**
* Get the note
*
* @return Note|null
*/
public static function get_note() {
if ( ! self::are_products_with_variations() ) {
return null;
}
$note = new Note();
$note->set_title( __( 'New - filter by product variations in orders and products reports', 'woocommerce-admin' ) );
$note->set_content( __( 'One of the most awaited features has just arrived! You can now have insights into each product variation in the orders and products reports.', 'woocommerce-admin' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_layout( 'banner' );
$note->set_image(
plugins_url(
'/images/admin_notes/filter-by-product-variations-note.svg',
WC_ADMIN_PLUGIN_FILE
)
);
$note->set_name( self::NOTE_NAME );
$note->set_content_data( (object) array() );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce-admin' ),
'https://docs.woocommerce.com/document/woocommerce-analytics/?utm_medium=product#variations-report'
);
return $note;
}
/**
* Returns whether or not there are variable products.
*
* @return bool If there are variable products
*/
private static function are_products_with_variations() {
$query = new \WC_Product_Query(
array(
'limit' => 1,
'paginate' => true,
'return' => 'ids',
'status' => array( 'publish' ),
'type' => array( 'variable' ),
)
);
$products = $query->get_products();
$count = $products->total;
return 0 !== $count;
}
}

View File

@ -1,82 +0,0 @@
<?php
/**
* WooCommerce Admin: Getting started in ecommerce, watch a webinar.
*
* Adds a note to remind the client they can watch a webinar to get started
* with WooCommerce.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Getting started in ecommmerce note class.
*/
class GettingStartedInEcommerceWebinar {
/**
* Note traits.
*/
use NoteTraits;
/**
* Onboarding traits.
*/
use OnboardingTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-getting-started-ecommerce-webinar';
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
if ( ! self::onboarding_profile_started() ) {
return;
}
if ( self::store_setup_for_client() ) {
return;
}
if ( ! self::revenue_is_within( 0, 2500 ) ) {
return;
}
// Don't show if there are products.
$query = new \WC_Product_Query(
array(
'limit' => 1,
'paginate' => true,
'return' => 'ids',
'status' => array( 'publish' ),
)
);
$products = $query->get_products();
$count = $products->total;
if ( 0 !== $count ) {
return;
}
$note = new Note();
$note->set_title( __( 'Getting Started in eCommerce - webinar', 'woocommerce-admin' ) );
$note->set_content( __( 'We want to make eCommerce and this process of getting started as easy as possible for you. Watch this webinar to get tips on how to have our store up and running in a breeze.', 'woocommerce-admin' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_content_data( (object) array() );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'getting-started-webinar',
__( 'Watch the webinar', 'woocommerce-admin' ),
'https://youtu.be/V_2XtCOyZ7o'
);
return $note;
}
}

View File

@ -1,83 +0,0 @@
<?php
/**
* WooCommerce Admin learn more about variable products note provider
*
* Adds a note when the store owner adds the first product.
*
* @package WooCommerce\Admin
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Class AddingAndManangingProducts
*
* @package Automattic\WooCommerce\Admin\Notes
*/
class LearnMoreAboutVariableProducts {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-learn-more-about-variable-products';
/**
* Add transition_post_status action.
*
* LearnMoreAboutVariableProducts constructor.
*/
public function __construct() {
add_action( 'transition_post_status', array( $this, 'maybe_add_new_note' ), 10, 3 );
}
/**
* Maybe attempt to add a new note if product is published.
*
* @param string $new_status new status.
* @param string $old_status old status.
* @param object $post post object.
*/
public function maybe_add_new_note( $new_status, $old_status, $post ) {
if ( 'publish' === $new_status && 'publish' !== $old_status && 'product' === $post->post_type ) {
$product = wc_get_product( $post->ID );
if ( ! $product ) {
return;
}
$product->is_type( 'simple' ) && static::possibly_add_note();
}
}
/**
* Get the note.
*
* @return Note|null
*/
public static function get_note() {
$note = new Note();
$note->set_title( __( 'Learn more about variable products', 'woocommerce-admin' ) );
$note->set_content(
__(
'Variable products are a powerful product type that lets you offer a set of variations on a product, with control over prices, stock, image and more for each variation. They can be used for a product like a shirt, where you can offer a large, medium and small and in different colors.',
'woocommerce-admin'
)
);
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'learn-more',
__( 'Learn more', 'woocommerce-admin' ),
'https://docs.woocommerce.com/document/variable-product/?utm_source=inbox&utm_medium=product'
);
return $note;
}
}

View File

@ -1,53 +0,0 @@
<?php
/**
* WooCommerce Admin Marketing Note Provider.
*
* Adds notes to the merchant's inbox concerning the marketing dashboard.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Marketing
*/
class Marketing {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-marketing-intro';
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
// Don't show the note unless the store has been active at least 5 days.
if ( ! self::is_wc_admin_active_in_date_range( 'week-1-4', 5 * DAY_IN_SECONDS ) ) {
return;
}
$note = new Note();
$note->set_title( __( 'Connect with your audience', 'woocommerce-admin' ) );
$note->set_content( __( 'Grow your customer base and increase your sales with marketing tools built for WooCommerce.', 'woocommerce-admin' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_content_data( (object) array() );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'open-marketing-hub',
__( 'Open marketing hub', 'woocommerce-admin' ),
admin_url( 'admin.php?page=wc-admin&path=/marketing' ),
Note::E_WC_ADMIN_NOTE_ACTIONED
);
return $note;
}
}

View File

@ -1,56 +0,0 @@
<?php
/**
* WooCommerce Admin Navigation Feature Feedback
*/
namespace Automattic\WooCommerce\Admin\Notes;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\Survey;
defined( 'ABSPATH' ) || exit;
/**
* NavigationFeedback
*/
class NavigationFeedback {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-navigation-feedback';
/**
* Should this note exist? (The navigation feature should exist.)
*/
public static function is_applicable() {
return Features::exists( 'navigation' );
}
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
if ( ! Features::is_enabled( 'navigation' ) ) {
return;
}
$content = __( "We're introducing the new navigation for a more intuitive and improved user experience. We'd like to hear your thoughts and first impressions.", 'woocommerce-admin' );
$note = new Note();
$note->set_title( __( 'You now have access to the new WooCommerce navigation', 'woocommerce-admin' ) );
$note->set_content( $content );
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'share-feedback', __( 'Share feedback', 'woocommerce-admin' ), Survey::get_url( '/new-navigation' ) );
return $note;
}
}

View File

@ -1,70 +0,0 @@
<?php
/**
* WooCommerce Admin Navigation Feature Feedback Follow Up.
*/
namespace Automattic\WooCommerce\Admin\Notes;
use Automattic\WooCommerce\Admin\Features\Features;
use Automattic\WooCommerce\Admin\Survey;
defined( 'ABSPATH' ) || exit;
/**
* NavigationFeedbackFollowUp
*/
class NavigationFeedbackFollowUp {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-navigation-feedback-follow-up';
/**
* Should this note exist? (The navigation feature should exist.)
*/
public static function is_applicable() {
return Features::exists( 'navigation' );
}
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
if ( ! Features::is_enabled( 'navigation' ) ) {
return;
}
// Check that the first note was created.
$data_store = Notes::load_data_store();
$note_ids = $data_store->get_notes_with_name( 'wc-admin-navigation-feedback' );
if ( empty( $note_ids ) ) {
return;
}
// Check that first note is at least 5 days old.
$note = Notes::get_note( $note_ids[0] );
$timestamp = strtotime( $note->get_date_created() );
if ( ( time() - $timestamp ) < DAY_IN_SECONDS * 5 ) {
return;
}
$content = __( "We recently introduced the new navigation for a more intuitive and improved user experience. Now that you've had some time to give it a try, let us know how this will impact your store.", 'woocommerce-admin' );
$note = new Note();
$note->set_title( __( 'Share your thoughts on the new WooCommerce navigation', 'woocommerce-admin' ) );
$note->set_content( $content );
$note->set_content_data( (object) array() );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_source( 'woocommerce-admin' );
$note->add_action( 'share-feedback', __( 'Share feedback', 'woocommerce-admin' ), Survey::get_url( '/new-navigation' ) );
return $note;
}
}

View File

@ -1,68 +0,0 @@
<?php
/**
* WooCommerce Admin: Do you need some inspiration?
*
* Adds a note to ask the client if they need some inspiration.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Need_Some_Inspiration.
*/
class NeedSomeInspiration {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-need-some-inspiration';
/**
* Get the note.
*
* @return Note
*/
public static function get_note() {
// We want to show the note after 4 days.
if ( ! self::is_wc_admin_active_in_date_range( 'week-1-4', 4 * 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 (
! isset( $onboarding_profile['setup_client'] ) ||
$onboarding_profile['setup_client']
) {
return;
}
$note = new Note();
$note->set_title( __( 'Browse our success stories', 'woocommerce-admin' ) );
$note->set_content( __( 'Learn more about how other entrepreneurs used WooCommerce to build successful businesses.', 'woocommerce-admin' ) );
$note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$note->set_name( self::NOTE_NAME );
$note->set_content_data( (object) array() );
$note->set_source( 'woocommerce-admin' );
$note->add_action(
'need-some-inspiration',
__( 'See success stories', 'woocommerce-admin' ),
'https://woocommerce.com/success-stories/?utm_source=inbox&utm_medium=product',
true
);
return $note;
}
}

View File

@ -1,82 +0,0 @@
<?php
/**
* WooCommerce Admin: Starting a dropshipping business.
*
* Adds a note to ask the client if they are considering starting a dropshipping business.
*/
namespace Automattic\WooCommerce\Admin\Notes;
defined( 'ABSPATH' ) || exit;
/**
* Start_Dropshipping_Business.
*/
class StartDropshippingBusiness {
/**
* Note traits.
*/
use NoteTraits;
/**
* Name of the note for use in the database.
*/
const NOTE_NAME = 'wc-admin-start-dropshipping-business';
/**
* Get the note.
*
* @return Note|null
*/
public static function get_note() {
// We want to show the note after one day.
if ( ! self::is_wc_admin_active_in_date_range( 'week-1', 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 (
! isset( $onboarding_profile['setup_client'] ) ||
$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 (
! isset( $onboarding_profile['product_count'] ) ||
! isset( $onboarding_profile['revenue'] ) ||
(
0 !== (int) $onboarding_profile['product_count'] &&
'none' !== $onboarding_profile['revenue'] &&
'up-to-2500' !== $onboarding_profile['revenue']
)
) {
return;
}
$note = new 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( Note::E_WC_ADMIN_NOTE_INFORMATIONAL );
$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&utm_medium=product',
Note::E_WC_ADMIN_NOTE_ACTIONED,
true
);
return $note;
}
}

View File

@ -1,54 +0,0 @@
<?php
/**
* Marketing note tests
*
* @package WooCommerce\Admin\Tests\Notes
*/
use \Automattic\WooCommerce\Admin\Notes\Marketing;
use Automattic\WooCommerce\Admin\Notes\Note;
/**
* Class WC_Tests_Marketing_Note
*/
class WC_Tests_Marketing_Note extends WC_Unit_Test_Case {
/**
* @var Marketing
*/
private $instance;
/**
* setUp
*/
public function setUp() {
parent::setUp();
$this->instance = new Marketing();
}
/**
* Given wc_admin is <= 5 days old
* When get_note() is called
* Then it should return null
*/
public function test_it_does_not_add_note_unless_5_days_old() {
update_option( 'woocommerce_admin_install_timestamp', time() );
$note = $this->instance->get_note();
$this->assertNull( $note );
}
/**
* Given wc_admin is >= 5 days old
* When get_note() is called
* Then it should not return null
*/
public function test_it_does_add_note_when_5_days_old() {
$five_days_ago = time() - 5 * 86400;
update_option( 'woocommerce_admin_install_timestamp', $five_days_ago );
$note = $this->instance->get_note();
$this->assertNotNull( $note );
}
}

View File

@ -1,169 +0,0 @@
<?php
/**
* LearnMoreAboutVariableProducts note tests
*
* @package WooCommerce\Admin\Tests\Notes
*/
use \Automattic\WooCommerce\Admin\Notes\LearnMoreAboutVariableProducts;
use \Automattic\WooCommerce\Admin\Notes\Notes;
/**
* Class WC_Tests_Marketing_Notes
*/
class WC_Tests_Learn_More_About_Variable_Product extends WC_Unit_Test_Case {
/**
* Reset the notes table for each test.
*/
public function setUp() {
parent::setUp();
global $wpdb;
$wpdb->query( "delete from {$wpdb->prefix}wc_admin_notes" );
}
/**
* Tests LearnMoreAboutVariableProducts gets created when a products gets published
*/
public function test_adding_note_when_product_gets_published() {
// Given a new product.
$product = array(
'post_title' => 'a product',
'post_type' => 'product',
'post_status' => 'publish',
'post_content' => '',
);
// When it is published.
wp_insert_post( $product );
// Then we should have LearnMoreAboutVariableProducts note.
$data_store = Notes::load_data_store();
$note_ids = $data_store->get_notes_with_name( LearnMoreAboutVariableProducts::NOTE_NAME );
$this->assertNotEmpty( $note_ids );
$this->assertCount( 1, $note_ids );
$note = Notes::get_note( $note_ids[0] );
$this->assertEquals( $note->get_name(), LearnMoreAboutVariableProducts::NOTE_NAME );
// Adding a second product does not create an additional note.
wp_insert_post( $product );
$note_ids = $data_store->get_notes_with_name( LearnMoreAboutVariableProducts::NOTE_NAME );
$this->assertNotEmpty( $note_ids );
$this->assertCount( 1, $note_ids );
}
/**
* Test a variable product does not create LearnMoreAboutVariableProducts note
*/
public function test_adding_variable_product_does_not_add_note() {
// Given a variable product.
$product = $this->create_variable_product();
// When it gets published.
wp_publish_post( $product->get_id() );
// Then a note should not be added.
$note_ids = $this->get_note_ids();
$note_count = count( $note_ids );
$this->assertEmpty( $note_ids, "{$note_count} notes found." );
}
/**
* @dataProvider postProvider
*
* @param string $product product from provider.
*/
public function test_adding_draft_product_and_non_product_post_does_not_add_note( $product ) {
wp_insert_post( $product );
$note_ids = $this->get_note_ids();
$note_count = count( $note_ids );
$this->assertEmpty( $note_ids, "{$note_count} notes found." );
}
/**
* Post provider for draft product and non-product post type
*
* @return array a set of posts.
*/
public function postProvider() {
return array(
array(
'post_title' => 'a product',
'post_type' => 'not a product',
'post_status' => 'publish',
'post_content' => '',
),
array(
'post_title' => 'a product',
'post_type' => 'product',
'post_status' => 'draft',
'post_content' => '',
),
);
}
/**
* Return note ids
* @return array
*/
protected function get_note_ids() {
$data_store = Notes::load_data_store();
return $data_store->get_notes_with_name( LearnMoreAboutVariableProducts::NOTE_NAME );
}
/**
* Create a variable product for testing
*
* @return WC_Product_Variable
*/
protected function create_variable_product() {
$name = 'test';
$product = new \WC_Product_Variable();
$attribute = new \WC_Product_Attribute();
$attribute->set_id( 0 );
$attribute->set_name( wp_rand( 1, 100 ) );
$attribute->set_options( array_filter( array( 1, 2 ) ) );
$attributes[] = $attribute;
$product->set_props(
array(
'name' => $name,
'featured' => wp_rand( 1, 10 ),
'attributes' => $attributes,
'status' => 'draft',
)
);
// Need to save to get an ID for variations.
$product->save();
// Create variations, one for each attribute value combination.
$variation_attributes = wc_list_pluck(
array_filter(
$product->get_attributes(),
'wc_attributes_array_filter_variation'
),
'get_slugs'
);
$possible_attributes = array_reverse( wc_array_cartesian( $variation_attributes ) );
foreach ( $possible_attributes as $possible_attribute ) {
$variation = new \WC_Product_Variation();
$variation->set_props(
array(
'parent_id' => $product->get_id(),
'attributes' => $possible_attribute,
'regular_price' => 10,
'stock_status' => 'instock',
)
);
$variation->save();
}
$data_store = $product->get_data_store();
$data_store->sort_all_product_variations( $product->get_id() );
return $product;
}
}