| @@ -44,8 +44,17 @@ | ||
| 44 | 44 | */ |
| 45 | 45 | private const USER_DETAILS_KEY = 'onboarding_user_details'; |
| 46 | 46 | |
| 47 | 47 | /** |
| 48 | + * Key inside suredonation_options recording when the onboarding lead was | |
| 49 | + * forwarded to the CRM. Stores a Unix timestamp; 0 means not yet sent. | |
| 50 | + * | |
| 51 | + * @since 1.1.2 | |
| 52 | + * @var string | |
| 53 | + */ | |
| 54 | + private const LEAD_SENT_KEY = 'onboarding_lead_sent_at'; | |
| 55 | + | |
| 56 | + /** | |
| 48 | 57 | * Hidden admin page slug. |
| 49 | 58 | * |
| 50 | 59 | * @since 1.0.0 |
| 51 | 60 | * @var string |
| @@ -112,8 +121,29 @@ | ||
| 112 | 121 | * @since 1.0.0 |
| 113 | 122 | */ |
| 114 | 123 | public function set_user_details( array $details ) { |
| 115 | 124 | Helper::update_suredonation_option( self::USER_DETAILS_KEY, $details ); |
| 125 | + } | |
| 126 | + | |
| 127 | + /** | |
| 128 | + * Whether the onboarding lead has already been forwarded to the CRM. | |
| 129 | + * | |
| 130 | + * @return bool | |
| 131 | + * @since 1.1.2 | |
| 132 | + */ | |
| 133 | + public function is_lead_sent() { | |
| 134 | + $sent_at = Helper::get_suredonation_option( self::LEAD_SENT_KEY, 0 ); | |
| 135 | + return is_numeric( $sent_at ) && (int) $sent_at > 0; | |
| 136 | + } | |
| 137 | + | |
| 138 | + /** | |
| 139 | + * Record that the onboarding lead has been forwarded to the CRM. | |
| 140 | + * | |
| 141 | + * @return void | |
| 142 | + * @since 1.1.2 | |
| 143 | + */ | |
| 144 | + public function mark_lead_sent() { | |
| 145 | + Helper::update_suredonation_option( self::LEAD_SENT_KEY, time() ); | |
| 116 | 146 | } |
| 117 | 147 | |
| 118 | 148 | /** |
| 119 | 149 | * On the first admin pageload after activation, send the admin to the |