Automattic\WooCommerce\Admin\Notes

DataStore::create()publicWC 1.0

Method to create a new note in the database.

Метод класса: DataStore{}

Хуки из метода

Возвращает

null. Ничего (null).

Использование

$DataStore = new DataStore();
$DataStore->create( $note );
$note(Note) (обязательный) (передается по ссылке — &)
Admin note.

Код DataStore::create() WC 8.7.0

public function create( &$note ) {
	$date_created = time();
	$note->set_date_created( $date_created );

	global $wpdb;

	$note_to_be_inserted = array(
		'name'         => $note->get_name(),
		'type'         => $note->get_type(),
		'locale'       => $note->get_locale(),
		'title'        => $note->get_title(),
		'content'      => $note->get_content(),
		'status'       => $note->get_status(),
		'source'       => $note->get_source(),
		'is_snoozable' => (int) $note->get_is_snoozable(),
		'layout'       => $note->get_layout(),
		'image'        => $note->get_image(),
		'is_deleted'   => (int) $note->get_is_deleted(),
	);

	$note_to_be_inserted['content_data']  = wp_json_encode( $note->get_content_data() );
	$note_to_be_inserted['date_created']  = gmdate( 'Y-m-d H:i:s', $date_created );
	$note_to_be_inserted['date_reminder'] = null;

	$wpdb->insert( $wpdb->prefix . 'wc_admin_notes', $note_to_be_inserted );
	$note_id = $wpdb->insert_id;
	$note->set_id( $note_id );
	$this->save_actions( $note );
	$note->apply_changes();

	/**
	 * Fires when an admin note is created.
	 *
	 * @param int $note_id Note ID.
	 */
	do_action( 'woocommerce_note_created', $note_id );
}