Change checkout tooltip to string
-
18-02-2021 - |
Question
I am working with a custom plugin in Magento 2 that adds two radio fields after all the other inputs. Here is a photo of what it looks like:
When you click on the question mark, a tooltip shows up with some text. I want that text to be displayed right next to "Is Tax Exempt" after the radio buttons instead of being a tooltip, so that the message is always displayed. Here is the current code:
<?php
namespace Module\Checkout\Plugin\Block;
class LayoutProcessorPlugin
{
public function afterProcess(\Magento\Checkout\Block\Checkout\LayoutProcessor $context, $result)
{
$newFields = [
'is_residential' => 'Is Residential',
'is_tax_exempt' => 'Is Tax Exempt',
];
$i = 1;
foreach ($newFields as $newField => $newFieldLabel) {
$customField = [
'component' => 'Magento_Ui/js/form/element/checkbox-set',
'config' => [
// customScope is used to group elements within a single form (e.g. they can be validated separately)
'customScope' => 'shippingAddress.custom_attributes',
'customEntry' => null,
'multiple' => false,
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/checkbox-set',
],
'additionalClasses' => 'custom-field-radio',
'dataScope' => 'shippingAddress.custom_attributes.' . $newField,
'label' => $newFieldLabel,
'provider' => 'checkoutProvider',
'sortOrder' => 200 + $i,
'validation' => [
'required-entry' => true
],
'filterBy' => null,
'customEntry' => null,
'visible' => true,
'options' => [
['value' => '1', 'label' => 'Yes'],
['value' => '0', 'label' => 'No'],
],
'valueMap' => [
'1' => true,
'0' => false
]
];
if ($newField == 'is_tax_exempt') {
$customField['tooltip']['description'] = 'Text I want to display next to radio buttons';
}
$result['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'][$newField] = $customField;
$i++;
}
return $result;
}
}
No correct solution
OTHER TIPS
Try following way:
$customField['config']['tooltip']['description'] = 'Text I want to display next to radio buttons';
Add below line after dataScope
'description' => __('custom text'),
Licensed under: CC-BY-SA with attribution
Not affiliated with magento.stackexchange