should_force_login() ? true : $required; } /** * Hide WooCommerce account-creation fields; OTP form handles auth. * * @param bool $enabled Registration enabled. */ public function disable_guest_registration_form( bool $enabled ): bool { return $this->should_force_login() ? false : $enabled; } /** * Show OTP login/register tabs instead of checkout for guests. */ public function render_force_login(): void { if ( ! $this->should_force_login() ) { return; } remove_action( 'woocommerce_before_checkout_form', 'woocommerce_checkout_login_form', 10 ); Assets::ensure(); $checkout_url = function_exists( 'wc_get_checkout_url' ) ? wc_get_checkout_url() : home_url( '/checkout/' ); $active_tab = 'login'; ?>

session ) { $verified = WC()->session->get( 'adev_otp_phone_verified' ); $session_ok = $verified && Phone::normalize( (string) $verified ) === $phone; } $transient_ok = (bool) get_transient( 'adev_otp_chk_' . md5( Rate_Limiter::client_ip() . $phone ) ); if ( '1' !== $flag && ! $session_ok && ! $transient_ok ) { wc_add_notice( __( 'Please verify your mobile number with the SMS code.', 'adev-otp-login' ), 'error' ); } } /** * Persist phone meta on order/user. * * @param int $order_id Order ID. */ public function save_phone( int $order_id ): void { $order = wc_get_order( $order_id ); if ( ! $order ) { return; } $phone = Phone::normalize( (string) $order->get_billing_phone() ); if ( ! $phone ) { return; } $user_id = $order->get_user_id(); if ( $user_id ) { Phone::save_for_user( $user_id, $phone ); } } }