NotificationStatus.php
63 lines
| 1 | <?php |
| 2 | |
| 3 | declare( strict_types = 1 ); |
| 4 | |
| 5 | namespace Automattic\WooCommerce\Internal\StockNotifications\Enums; |
| 6 | |
| 7 | /** |
| 8 | * Enum class for all the notification statuses. |
| 9 | */ |
| 10 | final class NotificationStatus { |
| 11 | |
| 12 | /** |
| 13 | * Status: 'pending'. |
| 14 | * Initial state when Double Opt-In (DOI) is active, awaiting user email verification. |
| 15 | * Not eligible for "back in stock" notifications until confirmed. |
| 16 | * |
| 17 | * @var string |
| 18 | */ |
| 19 | public const PENDING = 'pending'; |
| 20 | |
| 21 | /** |
| 22 | * Status: 'active'. |
| 23 | * User's subscription is confirmed and they are waiting for a "back in stock" alert. |
| 24 | * This is the default for new subscriptions if DOI is disabled, or after DOI confirmation. |
| 25 | * Notifications in this state are processed when the product is available. |
| 26 | * |
| 27 | * @var string |
| 28 | */ |
| 29 | public const ACTIVE = 'active'; |
| 30 | |
| 31 | /** |
| 32 | * Status: 'sent'. |
| 33 | * The "back in stock" notification email has been successfully dispatched. |
| 34 | * Typically a final state for that notification event. |
| 35 | * |
| 36 | * @var string |
| 37 | */ |
| 38 | public const SENT = 'sent'; |
| 39 | |
| 40 | /** |
| 41 | * Status: 'cancelled'. |
| 42 | * The notification is no longer active and will not be sent. |
| 43 | * The reason for cancellation should be in the `cancellation_source` field. |
| 44 | * |
| 45 | * @var string |
| 46 | */ |
| 47 | public const CANCELLED = 'cancelled'; |
| 48 | |
| 49 | /** |
| 50 | * Get all available notification statuses. |
| 51 | * |
| 52 | * @return array<string> Notification statuses. |
| 53 | */ |
| 54 | public static function get_valid_statuses(): array { |
| 55 | return array( |
| 56 | self::PENDING, |
| 57 | self::ACTIVE, |
| 58 | self::SENT, |
| 59 | self::CANCELLED, |
| 60 | ); |
| 61 | } |
| 62 | } |
| 63 |