Automattic\WooCommerce\Internal\DataStores\StockNotifications

StockNotificationsDataStore::delete │ public │ WC 1.0

Delete a stock notification.

Method of the class: StockNotificationsDataStore{}

Returns

void. Nothing (null).

Usage

$StockNotificationsDataStore = new StockNotificationsDataStore();
$StockNotificationsDataStore->delete( $notification, $args );
$notification(Notification) (required) (passed by reference — &)
The data object to delete.
$args(array)
Additional arguments.
Default: array()

StockNotificationsDataStore::delete() code WC 11.3.0

public function delete( &$notification, $args = array() ) {
	global $wpdb;

	$notification_id = $notification->get_id();
	$deleted         = $wpdb->delete( $this->get_table_name(), array( 'id' => $notification_id ), array( '%d' ) );

	if ( $deleted > 0 ) {
		$this->data_store_meta->delete_by_notification_id( $notification_id );

		/**
		 * Action: woocommerce_delete_stock_notification
		 *
		 * Fires after a stock notification is deleted, from any code path.
		 *
		 * @since 11.3.0
		 *
		 * @param int          $notification_id The deleted notification ID.
		 * @param Notification $notification    The notification, as it was before deletion.
		 */
		do_action( 'woocommerce_delete_stock_notification', $notification_id, $notification );
	}
}