diff --git a/plugins/woocommerce-admin/src/Events.php b/plugins/woocommerce-admin/src/Events.php index 3573553253a..28dfcdb4fe8 100644 --- a/plugins/woocommerce-admin/src/Events.php +++ b/plugins/woocommerce-admin/src/Events.php @@ -36,6 +36,7 @@ use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Learn_More_About_Product_ use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Online_Clothing_Store; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_First_Product; use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Customize_Store_With_Blocks; +use \Automattic\WooCommerce\Admin\Notes\WC_Admin_Notes_Facebook_Marketing_Expert; /** * WC_Admin_Events Class. @@ -103,6 +104,7 @@ class Events { WC_Admin_Notes_Choose_Niche::possibly_add_note(); WC_Admin_Notes_Real_Time_Order_Alerts::possibly_add_note(); WC_Admin_Notes_Customize_Store_With_Blocks::possibly_add_note(); + WC_Admin_Notes_Facebook_Marketing_Expert::possibly_add_note(); if ( Loader::is_feature_enabled( 'remote-inbox-notifications' ) ) { DataSourcePoller::read_specs_from_data_sources(); diff --git a/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Marketing_Expert.php b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Marketing_Expert.php new file mode 100644 index 00000000000..82e51175ea3 --- /dev/null +++ b/plugins/woocommerce-admin/src/Notes/WC_Admin_Notes_Facebook_Marketing_Expert.php @@ -0,0 +1,109 @@ +save(); + } + + /** + * Get the note. + */ + public static function get_note() { + $note = new WC_Admin_Note(); + $note->set_title( __( 'Create and optimise your Facebook ads with the help of a Facebook Marketing Expert', 'woocommerce-admin' ) ); + $note->set_content( __( 'Get 1:1 business support from a Facebook Marketing Expert who will work with you and your business to create and optimize your Facebook ads. Discover new strategies used by similar businesses in your market and industry. Check whether you are eligible to make use of this offer.', 'woocommerce-admin' ) ); + $note->set_type( WC_Admin_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( + 'learn-more', + __( 'Learn more', 'woocommerce-admin' ), + 'https://www.facebook.com/business/m/facebook-marketing-experts-program?content_id=UxWvEceBNtpQLhU', + WC_Admin_Note::E_WC_ADMIN_NOTE_ACTIONED, + true + ); + return $note; + } + + /** + * Determine if Facebook for WooCommerce is already active or installed + * + * @return bool + */ + protected static function is_facebook_for_woocommerce_installed() { + if ( class_exists( 'WC_Facebookcommerce_Integration' ) ) { + return true; + } + return PluginsHelper::is_plugin_installed( self::PLUGIN_FILE ); + } + + /** + * Determine the number of orders in the last month + * + * @return int + */ + protected static function orders_last_month() { + + $date = new \DateTime(); + + $args = array( + 'date_created' => '>' . $date->modify( '-1 month' )->format( 'Y-m-d' ), + 'return' => 'ids', + ); + + return count( wc_get_orders( $args ) ); + } +}