stone; } } return $milestone_reached; } /** * Get the appropriate note title for a given milestone. * * @param int $milestone Order milestone. * @return string Note title for the milestone. */ public static function get_note_title_for_milestone( $milestone ) { switch ( $milestone ) { case 1: return __( 'First order received', 'woocommerce' ); case 10: case 100: case 250: case 500: case 1000: case 5000: case 10000: case 500000: case 1000000: return sprintf( /* translators: Number of orders processed. */ __( 'Congratulations on processing %s orders!', 'woocommerce' ), wc_format_decimal( $milestone ) ); default: return ''; } } /** * Get the appropriate note content for a given milestone. * * @param int $milestone Order milestone. * @return string Note content for the milestone. */ public static function get_note_content_for_milestone( $milestone ) { switch ( $milestone ) { case 1: return __( 'Congratulations on getting your first order! Now is a great time to learn how to manage your orders.', 'woocommerce' ); case 10: return __( "You've hit the 10 orders milestone! Look at you go. Browse some WooCommerce success stories for inspiration.", 'woocommerce' ); case 100: case 250: case 500: case 1000: case 5000: case 10000: case 500000: case 1000000: return __( 'Another order milestone! Take a look at your Orders Report to review your orders to date.', 'woocommerce' ); default: return ''; } } /** * Get the appropriate note action for a given milestone. * * @param int $milestone Order milestone. * @return array Note actoion (name, label, query) for the milestone. */ public static function get_note_action_for_milestone( $milestone ) { switch ( $milestone ) { case 1: return array( 'name' => 'learn-more', 'label' => __( 'Learn more', 'woocommerce' ), 'query' => 'https://woocommerce.com/document/managing-orders/?utm_source=inbox&utm_medium=product', ); case 10: return array( 'name' => 'browse', 'label' => __( 'Browse', 'woocommerce' ), 'query' => 'https://woocommerce.com/success-stories/?utm_source=inbox&utm_medium=product', ); case 100: case 250: case 500: case 1000: case 5000: case 10000: case 500000: case 1000000: return array( 'name' => 'review-orders', 'label' => __( 'Review your orders', 'woocommerce' ), 'query' => '?page=wc-admin&path=/analytics/orders', ); default: return array( 'name' => '', 'label' => '', 'query' => '', ); } } /** * Convenience method to see if the milestone notes are enabled. * * @return boolean True if milestone notifications are enabled. */ public function are_milestones_enabled() { /** * Filter to allow for disabling order milestones. * * @since 3.7.0 * * @param boolean default true */ $milestone_notes_enabled = apply_filters( 'woocommerce_admin_order_milestones_enabled', true ); return $milestone_notes_enabled; } /** * Get the note. This is used for localizing the note. * * @return Note */ public static function get_note() { $note = Notes::get_note_by_name( self::NOTE_NAME ); if ( ! $note ) { return false; } $content_data = $note->get_content_data(); if ( ! isset( $content_data->current_milestone ) ) { return false; } return self::get_note_by_milestone( $content_data->current_milestone ); } /** * Get the note by milestones. * * @param int $current_milestone Current milestone. * * @return Note */ public static function get_note_by_milestone( $current_milestone ) { $content_data = (object) array( 'current_milestone' => $current_milestone, ); $note = new Note(); $note->set_title( self::get_note_title_for_milestone( $current_milestone ) ); $note->set_content( self::get_note_content_for_milestone( $current_milestone ) ); $note->set_content_data( $content_data ); $note->set_type( Note::E_WC_ADMIN_NOTE_INFORMATIONAL ); $note->set_name( self::NOTE_NAME ); $note->set_source( 'woocommerce-admin' ); $note_action = self::get_note_action_for_milestone( $current_milestone ); $note->add_action( $note_action['name'], $note_action['label'], $note_action['query'] ); return $note; } /** * Checks if a note can and should be added. * * @return bool */ public function can_be_added() { // If the milestone notes have been disabled via filter, bail. if ( ! $this->are_milestones_enabled() ) { return false; } $last_milestone = $this->get_last_milestone(); $current_milestone = $this->get_current_milestone(); if ( $current_milestone <= $last_milestone ) { return false; } return true; } /** * Add milestone notes for other significant thresholds. */ public function possibly_add_note() { if ( ! self::can_be_added() ) { return; } $current_milestone = $this->get_current_milestone(); $this->set_last_milestone( $current_milestone ); // We only want one milestone note at any time. Notes::delete_notes_with_name( self::NOTE_NAME ); $note = $this->get_note_by_milestone( $current_milestone ); $note->save(); } }
Fatal error: Uncaught Error: Class "Automattic\WooCommerce\Internal\Admin\Notes\OrderMilestones" not found in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php:176 Stack trace: #0 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(99): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->includes() #1 /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php(82): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->on_plugins_loaded() #2 /htdocs/wp-content/plugins/woocommerce/src/Admin/Composer/Package.php(65): Automattic\WooCommerce\Internal\Admin\FeaturePlugin->init() #3 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(64): Automattic\WooCommerce\Admin\Composer\Package::init() #4 /htdocs/wp-content/plugins/woocommerce/src/Packages.php(44): Automattic\WooCommerce\Packages::load_packages() #5 /htdocs/wp-includes/class-wp-hook.php(310): Automattic\WooCommerce\Packages::on_init('') #6 /htdocs/wp-includes/class-wp-hook.php(334): WP_Hook->apply_filters(NULL, Array) #7 /htdocs/wp-includes/plugin.php(517): WP_Hook->do_action(Array) #8 /htdocs/wp-settings.php(495): do_action('plugins_loaded') #9 /htdocs/wp-config.php(96): require_once('/htdocs/wp-sett...') #10 /htdocs/wp-load.php(50): require_once('/htdocs/wp-conf...') #11 /htdocs/wp-blog-header.php(13): require_once('/htdocs/wp-load...') #12 /htdocs/index.php(17): require('/htdocs/wp-blog...') #13 {main} thrown in /htdocs/wp-content/plugins/woocommerce/src/Internal/Admin/FeaturePlugin.php on line 176