Automattic\WooCommerce\Internal\Admin

Events::get_note_from_db()publicWC 1.0

Get note.

Method of the class: Events{}

No Hooks.

Return

null. Nothing (null).

Usage

$Events = new Events();
$Events->get_note_from_db( $note_from_db );
$note_from_db(Note) (required)
The note object from the database.

Events::get_note_from_db() code WC 8.6.1

public function get_note_from_db( $note_from_db ) {
	if ( ! $note_from_db instanceof Note || get_user_locale() === $note_from_db->get_locale() ) {
		return $note_from_db;
	}

	$note_classes = array_merge( self::$note_classes_to_added_or_updated, self::$other_note_classes );
	foreach ( $note_classes as $note_class ) {
		if ( defined( "$note_class::NOTE_NAME" ) && $note_class::NOTE_NAME === $note_from_db->get_name() ) {
			$note_from_class = method_exists( $note_class, 'get_note' ) ? $note_class::get_note() : null;

			if ( $note_from_class instanceof Note ) {
				$note = clone $note_from_db;
				$note->set_title( $note_from_class->get_title() );
				$note->set_content( $note_from_class->get_content() );
				$actions = $note_from_class->get_actions();
				foreach ( $actions as $action ) {
					$matching_action = $note->get_action( $action->name );
					if ( $matching_action && $matching_action->id ) {
						$action->id = $matching_action->id;
					}
				}
				$note->set_actions( $actions );
				return $note;
			}
			break;
		}
	}
	return $note_from_db;
}