Automattic\WooCommerce\Admin\Notes

Notes::trigger_note_action()public staticWC 1.0

Trigger note action.

Method of the class: Notes{}

Return

Note|true|false.

Usage

$result = Notes::trigger_note_action( $note, $triggered_action );
$note(Note) (required)
The note that has the triggered action.
$triggered_action(object) (required)
The triggered action.

Notes::trigger_note_action() code WC 8.7.0

public static function trigger_note_action( $note, $triggered_action ) {
	/**
	 * Fires when an admin note action is taken.
	 *
	 * @param string $name The triggered action name.
	 * @param Note   $note The corresponding Note.
	 */
	do_action( 'woocommerce_note_action', $triggered_action->name, $note );

	/**
	 * Fires when an admin note action is taken.
	 * For more specific targeting of note actions.
	 *
	 * @param Note $note The corresponding Note.
	 */
	do_action( 'woocommerce_note_action_' . $triggered_action->name, $note );

	// Update the note with the status for this action.
	if ( ! empty( $triggered_action->status ) ) {
		$note->set_status( $triggered_action->status );
	}

	$note->save();

	$event_params = array(
		'note_name'    => $note->get_name(),
		'note_type'    => $note->get_type(),
		'note_title'   => $note->get_title(),
		'note_content' => $note->get_content(),
		'action_name'  => $triggered_action->name,
		'action_label' => $triggered_action->label,
		'screen'       => self::get_screen_name(),
	);

	if ( in_array( $note->get_type(), array( 'error', 'update' ), true ) ) {
		wc_admin_record_tracks_event( 'store_alert_action', $event_params );
	} else {
		self::record_tracks_event_without_cookies( 'inbox_action_click', $event_params );
	}

	return $note;
}