Is anyone have an idea, how to convert XML to LayoutProcessor format?
Lose the last ['children']
.
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['telephone']
and make 'config' => ['elementTmpl' => 'ui/form/element/input']
look like this
'config' => ['elementTmpl' => 'ui/form/element/input', 'label' => __('Mobile phone number')]
follow the below code.
create di.xml at app/code/Vendor/Extension/frotend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="checkout_shipping" type="Vendor\Extension\Plugin\Checkout\Model\LayoutProcessor" sortOrder="150"/>
</type>
</config>
then create plugin file with layoutprocessor.php at Vendor\Extension\Plugin\Checkout\Model\LayoutProcessor.php
<?php
namespace Vendor\Extension\Plugin\Checkout\Model;
use Magento\Checkout\Block\Checkout\LayoutProcessor;
class LayoutProcessor
{
public function __construct(
\Magento\Payment\Model\Config $paymentModelConfig
)
{
$this->paymentModelConfig = $paymentModelConfig;
}
/* disable company from checkout page */
public function afterProcess(
LayoutProcessor $subject,
array $jsLayout
) {
/* For Disable Company field from checkout page shipping form */
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['telephone'] = [
'config' => ['elementTmpl' => 'ui/form/element/input'],
'dataScope' => '1',
'provider' => 'checkoutProvider',
'validation' => ['custom-validator-phone' => true],
];
$activePayments = $this->paymentModelConfig->getActiveMethods();
/* For Disable company field from checkout billing form */
if (count($activePayments)) {
foreach ($activePayments as $paymentCode => $payment) {
$jsLayout['components']['checkout']['children']['steps']['children']
['billing-step']['children']['payment']['children']
['payments-list']['children'][$paymentCode.'-form']['children']
['form-fields']['children']['company'] = [
'config' => ['elementTmpl' => 'ui/form/element/input'],
'dataScope' => '1',
'provider' => 'checkoutProvider',
'validation' => ['custom-validator-phone' => true],
];
}
}
return $jsLayout;
}
}