I want to auto check the first gender selection option, to be checked by default in the checkout.
I changed the default selection option to a radio button selection.
How can I achieve this?
My current code:
VendorName/ModuleName/Plugin/Block/LayoutProcessor.php
namespace VendorName\ModuleName\Plugin\Block;
class LayoutProcessor
{
/**
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* @param array $jsLayout
* @return array
*/
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
) {
if(isset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset'])) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['prefix']['component'] = "Magento_Ui/js/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['prefix']['config']['elementTmpl'] = "ui/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['prefix']['config']['multiple'] = false;
}
if(isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list'])) {
$paymentsList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'];
foreach ($paymentsList as $paymentCode => $payment) {
if(strpos($paymentCode, '-form') === false) {
continue;
}
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'][$paymentCode]['children']['form-fields']['children']['prefix']['component'] = "Magento_Ui/js/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'][$paymentCode]['children']['form-fields']['children']['prefix']['config']['elementTmpl'] = "ui/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['payments-list']['children'][$paymentCode]['children']['form-fields']['children']['prefix']['config']['multiple'] = false;
}
}
if(isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['afterMethods']['children']['billing-address-form'])) {
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children']['prefix']['component'] = "Magento_Ui/js/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children']['prefix']['config']['elementTmpl'] = "ui/form/element/checkbox-set";
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children']['prefix']['config']['multiple'] = false;
}
return $jsLayout;
}
}