I have create a custom module i have to add the custom dropdown at checkout page through my custom module can anyone guide me about this how i can do that?
Solved! Go to Solution.
Hello @amarpreetbd709
Overwrite Magento\Checkout\Block\Checkout\LayoutProcessor process method in your custom module. So create a plugin,
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;
}
}
Hello @amarpreetbd709
Overwrite Magento\Checkout\Block\Checkout\LayoutProcessor process method in your custom module. So create a plugin,
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;
}
}
Hello @gaurav_harsh1
I want to remove the default apply coupon functionality and want to add my own custom coupon functionality in same place can u help me in this
Thanks in Advance!