Automattic\WooCommerce\Internal\PushNotifications\Triggers
StockNotificationTrigger::add_notification
Creates a stock notification and adds it to the pending store.
Method of the class: StockNotificationTrigger{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->add_notification( $product_id, $event_type, ?int $stock_quantity_at_trigger ): void;
- $product_id(int) (required)
- The product ID.
- $event_type(string) (required)
- The stock event type.
- ?int $stock_quantity_at_trigger
- .
Default:null
StockNotificationTrigger::add_notification() StockNotificationTrigger::add notification code WC 10.9.1
private function add_notification( int $product_id, string $event_type, ?int $stock_quantity_at_trigger = null ): void {
if ( $product_id <= 0 ) {
return;
}
wc_get_container()->get( PendingNotificationStore::class )->add(
new StockNotification( $product_id, $event_type, $stock_quantity_at_trigger )
);
}