I want to add custom dropdown in checkout page where dropdown contain following value:option1 and option2
-
In which section do you want dropdown like shipping address etc..?Chirag Patel– Chirag Patel2019-05-29 09:54:23 +00:00Commented May 29, 2019 at 9:54
-
on which step?\Amit Bera– Amit Bera ♦2019-05-29 10:09:56 +00:00Commented May 29, 2019 at 10:09
-
Shipping Address @ChiragPatelVardhman Kamani– Vardhman Kamani2019-05-29 10:32:01 +00:00Commented May 29, 2019 at 10:32
-
Shipping Address @AmitBeraVardhman Kamani– Vardhman Kamani2019-05-29 10:32:15 +00:00Commented May 29, 2019 at 10:32
Add a comment
|
1 Answer
Overwrite Magento\Checkout\Block\Checkout\LayoutProcessor process method in your custom module. So create a plugin,
Namespace/CheckoutAdditionalField/Plugin/Checkout/Model/Checkout/LayoutProcessor.php
namespace Namespace\CheckoutAdditionalField\Plugin\Checkout\Model\Checkout;
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
) {
$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' => [],
'id' => 'delivery-date'
],
'dataScope' => 'shippingAddress.delivery_date',
'label' => 'Delivery Date',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 250,
'id' => 'delivery-date'
];
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['drop_down'] = [
'component' => 'Magento_Ui/js/form/element/select',
'config' => [
'customScope' => 'shippingAddress',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'id' => 'drop-down',
],
'dataScope' => 'shippingAddress.drop_down',
'label' => 'Drop Down',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 251,
'id' => 'drop-down',
'options' => [
[
'value' => '',
'label' => 'Please Select',
],
[
'value' => '1',
'label' => 'First Option',
]
]
];
return $jsLayout;
}
}
I hope it helps!
-
How can value store in database? @Chirag PatelVardhman Kamani– Vardhman Kamani2019-05-29 10:56:20 +00:00Commented May 29, 2019 at 10:56
-
Let me see and get back to you once i found something about save data to database.Chirag Patel– Chirag Patel2019-05-29 10:58:19 +00:00Commented May 29, 2019 at 10:58
-
Create
UpgradeSchema.phpfile in your custom module. and follow this to create a field in database magento.stackexchange.com/questions/126036/…Chirag Patel– Chirag Patel2019-05-29 11:32:55 +00:00Commented May 29, 2019 at 11:32 -
and How to add dropdown in Review & Payment Step? @Chirag PatelVardhman Kamani– Vardhman Kamani2019-05-30 06:42:05 +00:00Commented May 30, 2019 at 6:42
-
Not getting your point explain more..Chirag Patel– Chirag Patel2019-05-30 07:14:12 +00:00Commented May 30, 2019 at 7:14