Automattic\WooCommerce\Internal\StockNotifications

Notification::savepublicWC 1.0

Save the notification.

Method of the class: Notification{}

No Hooks.

Returns

Int|\WP_Error. The notification ID or a WP_Error if the save failed.

Usage

$Notification = new Notification();
$Notification->save();

Notification::save() code WC 10.3.6

public function save() {
	if ( ! $this->data_store ) {
		return $this->get_id();
	}

	try {
		$this->validate_props();
	} catch ( \WC_Data_Exception $e ) {
		return new \WP_Error( 'stock_notification_validation_error', $e->getMessage() );
	}

	if ( $this->get_id() ) {
		$this->data_store->update( $this );
	} else {
		$this->data_store->create( $this );
	}

	return $this->get_id();
}