22/**
33 * Email Verification for WooCommerce - Guest Verification.
44 *
5- * @version 3.1.2
5+ * @version 3.1.3
66 * @since 2.8.0
77 * @author WPFactory
88 */
@@ -197,29 +197,48 @@ function alg_wc_ev_send_guest_verification_email_action( $param ) {
197197 /**
198198 * checkout_validate_guest_email.
199199 *
200- * @version 3.1.2
200+ * @version 3.1.3
201201 * @since 2.5.8
202202 *
203203 * @return string
204204 */
205205 function checkout_validate_guest_email ( $ _posted , $ errors ) {
206+ if ( $ this ->need_to_validate_guest_email_and_posted_email_is_wrong ( $ _posted ) ) {
207+ $ errors ->add ( 'alg_wc_ev_verify_guest_email ' , alg_wc_ev ()->core ->messages ->get_guest_unverified_message () );
208+ }
209+ }
210+
211+ /**
212+ * need_to_validate_guest_email_and_posted_email_is_wrong.
213+ *
214+ * @version 3.1.3
215+ * @since 3.1.3
216+ *
217+ * @param $posted
218+ *
219+ * @return bool
220+ */
221+ function need_to_validate_guest_email_and_posted_email_is_wrong ( $ posted ) {
222+ $ response = false ;
206223 if (
207224 'yes ' === get_option ( 'alg_wc_ev_verify_guest_email ' , 'no ' ) &&
208225 ! is_user_logged_in () &&
209226 (
210- ( isset ( $ _posted ['billing_email ' ] ) && ! empty ( $ _posted ['billing_email ' ] ) && ! $ this ->is_guest_email_already_verified ( $ _posted ['billing_email ' ] ) ) ||
211- ( isset ( $ _posted ['billing_email ' ] ) && empty ( $ _posted ['billing_email ' ] ) ) ||
212- ! isset ( $ _posted ['billing_email ' ] )
227+ ( isset ( $ posted ['billing_email ' ] ) && ! empty ( $ posted ['billing_email ' ] ) && ! $ this ->is_guest_email_already_verified ( $ posted ['billing_email ' ] ) ) ||
228+ ( isset ( $ posted ['billing_email ' ] ) && empty ( $ posted ['billing_email ' ] ) ) ||
229+ ! isset ( $ posted ['billing_email ' ] )
213230 )
214231 ) {
215- $ errors -> add ( ' alg_wc_ev_verify_guest_email ' , alg_wc_ev ()-> core -> messages -> get_guest_unverified_message () ) ;
232+ $ response = true ;
216233 }
234+
235+ return $ response ;
217236 }
218237
219238 /**
220239 * checkout_validate_guest_email_on_checkout_create_order.
221240 *
222- * @version 3.1.0
241+ * @version 3.1.3
223242 * @since 3.0.4
224243 *
225244 * @param $order
@@ -229,12 +248,7 @@ function checkout_validate_guest_email( $_posted, $errors ) {
229248 * @return mixed
230249 */
231250 function checkout_validate_guest_email_on_checkout_create_order ( $ order , $ _posted ) {
232- if (
233- 'yes ' === get_option ( 'alg_wc_ev_verify_guest_email ' , 'no ' ) &&
234- ! is_user_logged_in () &&
235- ( isset ( $ _posted ['billing_email ' ] ) && ! empty ( $ _posted ['billing_email ' ] ) && ! $ this ->is_guest_email_already_verified ( $ _posted ['billing_email ' ] ) ) ||
236- ( ! isset ( $ _posted ['billing_email ' ] ) || empty ( $ _posted ['billing_email ' ] ) )
237- ) {
251+ if ( $ this ->need_to_validate_guest_email_and_posted_email_is_wrong ( $ _posted ) ) {
238252 $ message = alg_wc_ev ()->core ->messages ->get_guest_unverified_message ();
239253 throw new Exception ( $ message );
240254 }
0 commit comments