How to add two custom fields for all payment methods in my payment section of magento 2,Can any one help me on this?
$jsLayout['components']['checkout']['children']['steps']['children']['payment']['children']
['methods']['children']['paymentAdditional'] = [
'component' => 'uiComponent',
'displayArea' => 'paymentAdditional',
'children' => [
'delivery_date' => [
'component' => Vendor_Module/js/view/payment/method-renderer/taxInfo-comp',
'config' => [
'customScope' => 'methods',
'template' => 'ui/form/field',
'elementTmpl' => 'vendor_module/payment/taxinfo-form',
'options' => [],
],
'dataScope' => 'methods.tax_code',
'label' => 'Tax Code',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => false, //['required-entry' => $this->_helper->getConfigIsFieldRequired()],
'sortOrder' => 200,
]
],
];
-
1Please elaborate your requirements by for which purpose you need those custom fields? This thread may help you linkRajesh Elangovan– Rajesh Elangovan2016年11月21日 12:39:25 +00:00Commented Nov 21, 2016 at 12:39
-
i want to add tax related information for all payment methods.please check this link magentocommerce.com/magento-connect/sales-tax-exempt.htmlrajat kara– rajat kara2016年11月21日 12:42:29 +00:00Commented Nov 21, 2016 at 12:42
-
Am not aware of Magento 2,but for magento 1.9 versions you can make use of these linkRajesh Elangovan– Rajesh Elangovan2016年11月21日 13:04:26 +00:00Commented Nov 21, 2016 at 13:04
1 Answer 1
If You want two add new custom field for all payment method in payment section of magento 2
you can overwrite \Magento\Checkout\Block\Checkout\LayoutProcessor
follow this sequence
/[vendor]/[module]/etc/frontend/di.xml
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor">
<plugin name="checkout_custom_fields" type="vendor\module\Plugin\Checkout\LayoutProcessor" sortOrder="100"/>
</type>
vandor/module/Model/Checkout/LayoutProcessorPlugin.php
namespace vendor\module\Model\Checkout;
class LayoutProcessorPlugin
{
/**
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* @param array $jsLayout
* @return array
*/
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
) {
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['delivery_date'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/date',
'options' => [],
],
'dataScope' => 'shippingAddress.your_field',
'label' => 'field label',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 200
];
return $jsLayout;
}
}
-
1The above code is for shipping method.in payment section not working.i have already tried.and the path is incorrect it should be \Magento\Checkout\Model\Checkout\LayoutProcessorrajat kara– rajat kara2016年11月21日 13:10:12 +00:00Commented Nov 21, 2016 at 13:10
-
can you please upload screen short where you need add costume field.user44966– user449662016年11月21日 13:12:01 +00:00Commented Nov 21, 2016 at 13:12
-
Please check the code in my question.rajat kara– rajat kara2016年11月21日 13:17:17 +00:00Commented Nov 21, 2016 at 13:17
-
You can follow [Reference link] below at my answer. This is working .user44966– user449662016年11月21日 13:20:57 +00:00Commented Nov 21, 2016 at 13:20
-
I have already checked in payment method,not working but in shipping method its working.rajat kara– rajat kara2016年11月21日 13:22:12 +00:00Commented Nov 21, 2016 at 13:22
Explore related questions
See similar questions with these tags.