46 lines
966 B
PHP
46 lines
966 B
PHP
<?php
|
|
/**
|
|
* @package ogre-captcha
|
|
* @author cleverogre
|
|
* @copyright 2026 CleverOgre
|
|
* @license GLP-3.0-or-later
|
|
* @version 1.0.0
|
|
* @since 1.0.0
|
|
*/
|
|
|
|
namespace Ogre\Captcha\Location\WooCommerce;
|
|
|
|
use Override;
|
|
use Ogre\Captcha\Location;
|
|
use Ogre\Captcha\Settings;
|
|
use WP_Error;
|
|
|
|
defined('ABSPATH') || exit;
|
|
|
|
final class Checkout extends Location {
|
|
|
|
protected function __construct() {
|
|
parent::__construct(Settings::LOCATION_WC_CHECKOUT);
|
|
}
|
|
|
|
#[Override]
|
|
public function enabled(): bool
|
|
{
|
|
return is_user_logged_in() ? false : parent::enabled();
|
|
}
|
|
|
|
#[Override]
|
|
public function activate(): void
|
|
{
|
|
add_action('woocommerce_after_checkout_billing_form', [$this, 'render']);
|
|
add_action('woocommerce_after_checkout_validation', [$this, 'process_form'], 10, 2);
|
|
}
|
|
|
|
public function process_form(array $data, WP_Error $errors) {
|
|
$this->process($errors);
|
|
}
|
|
|
|
}
|
|
|
|
Checkout::instance();
|