-
Notifications
You must be signed in to change notification settings - Fork 9.4k
/
Copy pathCheckoutLayoutProcessor.php
45 lines (41 loc) · 1.35 KB
/
CheckoutLayoutProcessor.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
/**
* Copyright 2025 Adobe.
* All Rights Reserved.
*/
declare(strict_types=1);
namespace Magento\Captcha\Block;
use Magento\Checkout\Block\Checkout\LayoutProcessorInterface;
use Magento\Captcha\Helper\Data as HelperCaptcha;
class CheckoutLayoutProcessor implements LayoutProcessorInterface
{
/**
* @param HelperCaptcha $helper
*/
public function __construct(
private readonly HelperCaptcha $helper
) {
}
/**
* Remove captcha from checkout page if it is disabled
*
* @param array $jsLayout
* @return array
*/
public function process($jsLayout): array
{
if ($this->helper->getConfig('enable')) {
$captcha = [
'component' => 'Magento_Captcha/js/view/checkout/loginCaptcha',
'displayArea' => 'additional-login-form-fields',
'formId' => 'user_login',
'configSource' => 'checkoutConfig'
];
$jsLayout['components']['checkout']['children']['authentication']['children']['captcha'] = $captcha;
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['customer-email']['children']['additional-login-form-fields']
['children']['captcha'] = $captcha;
}
return $jsLayout;
}
}