Automattic\WooCommerce\Admin\Notes

Notes::possibly_delete_marketing_notes()public staticWC 1.0

Delete marketing notes if marketing has been opted out.

{} It's a method of the class: Notes{}

No Hooks.

Return

null. Nothing.

Usage

$result = Notes::possibly_delete_marketing_notes( $old_value, $value );
$old_value(string) (required)
Old value.
$value(string) (required)
New value.

Code of Notes::possibly_delete_marketing_notes() WC 6.6.1

public static function possibly_delete_marketing_notes( $old_value, $value ) {
	if ( 'no' !== $value ) {
		return;
	}

	$data_store = self::load_data_store();
	$note_ids   = $data_store->get_note_ids_by_type( Note::E_WC_ADMIN_NOTE_MARKETING );

	foreach ( $note_ids as $note_id ) {
		$note = self::get_note( $note_id );
		if ( $note ) {
			$note->delete();
		}
	}
}