get_id(); if ( $product_id <= 0 ) { return; } $stock_quantity = $product->get_stock_quantity(); if ( null === $stock_quantity ) { return; } $stock = (int) $stock_quantity; if ( $stock > (int) wc_get_low_stock_amount( $product ) ) { $this->clear_meta( $product_id, StockNotification::EVENT_LOW_STOCK ); } if ( $stock > (int) get_option( 'woocommerce_notify_no_stock_amount', 0 ) ) { $this->clear_meta( $product_id, StockNotification::EVENT_OUT_OF_STOCK ); } if ( $stock >= 0 ) { $this->clear_meta( $product_id, StockNotification::EVENT_ON_BACKORDER ); } } /** * Clears the namespaced sent-meta for a given product and event subtype. * * @param int $product_id The product ID. * @param string $event_type One of the StockNotification::EVENT_* constants. * @return void */ private function clear_meta( int $product_id, string $event_type ): void { ( new StockNotification( $product_id, $event_type ) )->delete_meta( NotificationProcessor::SENT_META_KEY ); } }