Admin
1 month ago
AsyncTasks
1 month ago
Emails
1 month ago
Enums
10 months ago
Frontend
1 month ago
Privacy
1 month ago
Utilities
1 month ago
Config.php
1 month ago
DataRetentionController.php
1 month ago
Factory.php
10 months ago
Notification.php
1 month ago
NotificationQuery.php
10 months ago
StockNotifications.php
1 month ago
StockSyncController.php
10 months ago
NotificationQuery.php
53 lines
| 1 | <?php |
| 2 | declare( strict_types=1 ); |
| 3 | |
| 4 | namespace Automattic\WooCommerce\Internal\StockNotifications; |
| 5 | |
| 6 | /** |
| 7 | * Notification query class. |
| 8 | */ |
| 9 | class NotificationQuery { |
| 10 | |
| 11 | /** |
| 12 | * Get notifications. |
| 13 | * |
| 14 | * @param array $args The arguments to pass to the query. |
| 15 | * @return array The notifications. |
| 16 | */ |
| 17 | public static function get_notifications( array $args ): array { |
| 18 | return \WC_Data_Store::load( 'stock_notification' )->query( $args ); |
| 19 | } |
| 20 | |
| 21 | /** |
| 22 | * Check if a product has active notifications. |
| 23 | * |
| 24 | * @param array<int> $product_ids The product IDs to check. |
| 25 | * @return bool True if the product has active notifications, false otherwise. |
| 26 | */ |
| 27 | public static function product_has_active_notifications( array $product_ids ): bool { |
| 28 | return \WC_Data_Store::load( 'stock_notification' )->product_has_active_notifications( $product_ids ); |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Check if a notification exists by email. |
| 33 | * |
| 34 | * @param int $product_id The product ID. |
| 35 | * @param string $email The email address. |
| 36 | * @return bool True if the notification exists, false otherwise. |
| 37 | */ |
| 38 | public static function notification_exists_by_email( int $product_id, string $email ): bool { |
| 39 | return \WC_Data_Store::load( 'stock_notification' )->notification_exists_by_email( $product_id, $email ); |
| 40 | } |
| 41 | |
| 42 | /** |
| 43 | * Get a notification by user ID. |
| 44 | * |
| 45 | * @param int $product_id The product ID. |
| 46 | * @param int $user_id The user ID. |
| 47 | * @return bool True if the notification exists, false otherwise. |
| 48 | */ |
| 49 | public static function notification_exists_by_user_id( int $product_id, int $user_id ): bool { |
| 50 | return \WC_Data_Store::load( 'stock_notification' )->notification_exists_by_user_id( $product_id, $user_id ); |
| 51 | } |
| 52 | } |
| 53 |