WooCommerce Code Reference

Notes
in package

Admin Notes class.

Table of Contents

UNSNOOZE_HOOK  = 'wc_admin_unsnooze_admin_notes'
Hook used for recurring "unsnooze" action.
clear_queued_actions()  : mixed
Unschedule unsnooze notes event.
delete_all_notes()  : array<string|int, mixed>
Soft delete of all the admin notes. Returns the deleted items.
delete_note()  : mixed
Soft delete of a note.
delete_notes_with_name()  : mixed
Deletes admin notes with a given name.
get_action_by_id()  : object|bool
Get action by id.
get_note()  : Note|bool
Get admin note using it's ID
get_note_by_name()  : Note|bool
Get admin note using its name.
get_note_status()  : string|bool
Get the status of a given note by name.
get_notes()  : array<string|int, mixed>
Get notes from the database.
get_notes_count()  : int
Get the total number of notes
get_screen_name()  : string
Get screen name.
init()  : mixed
Hook appropriate actions.
load_data_store()  : WC_Data_Store
Loads the data store.
possibly_delete_marketing_notes()  : mixed
Delete marketing notes if marketing has been opted out.
possibly_delete_survey_notes()  : mixed
Delete actioned survey notes.
record_tracks_event_with_user()  : mixed
Record tracks event for a specific user.
schedule_unsnooze_notes()  : mixed
Schedule unsnooze notes event.
trigger_note_action()  : Note|bool
Trigger note action.
unsnooze_notes()  : mixed
Clear note snooze status if the reminder date has been reached.
update_note()  : mixed
Update a note.
record_tracks_event_without_cookies()  : mixed
Record tracks event without using cookies.

Constants

UNSNOOZE_HOOK

Hook used for recurring "unsnooze" action.

public mixed UNSNOOZE_HOOK = 'wc_admin_unsnooze_admin_notes'

Methods

clear_queued_actions()

Unschedule unsnooze notes event.

public static clear_queued_actions() : mixed
Return values
mixed

delete_all_notes()

Soft delete of all the admin notes. Returns the deleted items.

public static delete_all_notes([array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$args : array<string|int, mixed> = array()

Arguments to pass to the query (ex: status).

Return values
array<string|int, mixed>Array of notes.

delete_note()

Soft delete of a note.

public static delete_note(Note $note) : mixed
Parameters
$note : Note

The note that will be deleted.

Return values
mixed

delete_notes_with_name()

Deletes admin notes with a given name.

public static delete_notes_with_name(string|array<string|int, mixed> $names) : mixed
Parameters
$names : string|array<string|int, mixed>

Name(s) to search for.

Return values
mixed

get_action_by_id()

Get action by id.

public static get_action_by_id(Note $note, int $action_id) : object|bool
Parameters
$note : Note

The note that has of the action.

$action_id : int

Action ID.

Return values
object|boolThe found action.

get_note()

Get admin note using it's ID

public static get_note(int $note_id) : Note|bool
Parameters
$note_id : int

Note ID.

Return values
Note|bool

get_note_by_name()

Get admin note using its name.

public static get_note_by_name(string $note_name) : Note|bool

This is a shortcut for the common pattern of looking up note ids by name and then passing the first id to get_note(). It will behave unpredictably when more than one note with the given name exists.

Parameters
$note_name : string

Note name.

Return values
Note|bool

get_note_status()

Get the status of a given note by name.

public static get_note_status(string $note_name) : string|bool
Parameters
$note_name : string

Name of the note.

Return values
string|boolThe note status.

get_notes()

Get notes from the database.

public static get_notes([string $context = 'edit' ][, array<string|int, mixed> $args = array() ]) : array<string|int, mixed>
Parameters
$context : string = 'edit'

Getting notes for what context. Valid values: view, edit.

$args : array<string|int, mixed> = array()

Arguments to pass to the query( e.g. per_page and page).

Return values
array<string|int, mixed>Array of arrays.

get_notes_count()

Get the total number of notes

public static get_notes_count([string $type = array() ][, string $status = array() ]) : int
Parameters
$type : string = array()

Comma separated list of note types.

$status : string = array()

Comma separated list of statuses.

Return values
int

get_screen_name()

Get screen name.

public static get_screen_name() : string
Return values
stringThe screen name.

load_data_store()

Loads the data store.

public static load_data_store() : WC_Data_Store

If the "admin-note" data store is unavailable, attempts to load it will result in an exception. This method catches that exception and throws a custom one instead.

Tags
throws
NotesUnavailableException

Throws exception if data store loading fails.

Return values
WC_Data_StoreThe "admin-note" data store.

possibly_delete_marketing_notes()

Delete marketing notes if marketing has been opted out.

public static possibly_delete_marketing_notes(string $old_value, string $value) : mixed
Parameters
$old_value : string

Old value.

$value : string

New value.

Return values
mixed

possibly_delete_survey_notes()

Delete actioned survey notes.

public static possibly_delete_survey_notes() : mixed
Return values
mixed

record_tracks_event_with_user()

Record tracks event for a specific user.

public static record_tracks_event_with_user(int $user_id, string $event_name, array<string|int, mixed> $params) : mixed
Parameters
$user_id : int

The user id we want to record for the event.

$event_name : string

Name of the event to record.

$params : array<string|int, mixed>

The params to send to the event recording.

Return values
mixed

schedule_unsnooze_notes()

Schedule unsnooze notes event.

public static schedule_unsnooze_notes() : mixed
Return values
mixed

trigger_note_action()

Trigger note action.

public static trigger_note_action(Note $note, object $triggered_action) : Note|bool
Parameters
$note : Note

The note that has the triggered action.

$triggered_action : object

The triggered action.

Return values
Note|bool

unsnooze_notes()

Clear note snooze status if the reminder date has been reached.

public static unsnooze_notes() : mixed
Return values
mixed

update_note()

Update a note.

public static update_note(Note $note, array<string|int, mixed> $requested_updates) : mixed
Parameters
$note : Note

The note that will be updated.

$requested_updates : array<string|int, mixed>

a list of requested updates.

Return values
mixed

record_tracks_event_without_cookies()

Record tracks event without using cookies.

private static record_tracks_event_without_cookies(string $event_name, array<string|int, mixed> $params) : mixed
Parameters
$event_name : string

Name of the event to record.

$params : array<string|int, mixed>

The params to send to the event recording.

Return values
mixed