Magento 2 checkout - add a custom field between shipping address and shipping method Planned...

An adverb for when you're not exaggerating

How can I reduce the gap between left and right of cdot with a macro?

Do I really need to have a message in a novel to appeal to readers?

Selecting user stories during sprint planning

Is there hard evidence that the grant peer review system performs significantly better than random?

What was the first language to use conditional keywords?

Is a ledger board required if the side of my house is wood?

Significance of Cersei's obsession with elephants?

AppleTVs create a chatty alternate WiFi network

Why is my ESD wriststrap failing with nitrile gloves on?

Converted a Scalar function to a TVF function for parallel execution-Still running in Serial mode

Take 2! Is this homebrew Lady of Pain warlock patron balanced?

How come Sam didn't become Lord of Horn Hill?

Why does the remaining Rebel fleet at the end of Rogue One seem dramatically larger than the one in A New Hope?

Using audio cues to encourage good posture

How to compare two different files line by line in unix?

Is it fair for a professor to grade us on the possession of past papers?

Generate an RGB colour grid

Why does it sometimes sound good to play a grace note as a lead in to a note in a melody?

Why should I vote and accept answers?

How to tell that you are a giant?

Sum letters are not two different

Most bit efficient text communication method?

What do you call the main part of a joke?



Magento 2 checkout - add a custom field between shipping address and shipping method



Planned maintenance scheduled April 23, 2019 at 00:00UTC (8:00pm US/Eastern)
Announcing the arrival of Valued Associate #679: Cesar Manara
Unicorn Meta Zoo #1: Why another podcast?Magento 2 - How to add a custom field to checkout and then send itHow to Add Custom fields to Checkout page in Magento2How to get and set data in checkout shipping address magento 2?Add custom field to checkoutHow to add new custom field to billing address section in magento2How to get the value of custom field checkout address in Carrier Model Magento 2custom shipping address date field validationcustom field value not showing in shipping address in magento backendSave Custom field in shipping address at Checkout in Magento 2Magento 2.2: How to save data from custom field in sales_order_address table?Add Customer Note (comments) on billing Address and Save itHow to add custom shipping field to the shipping method list on checkout page in magento 2What is the best way to save a custom field in shipping address?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







17















I'm trying to add a custom field in between the shipping address and shipping method sections. And I want values of this field to be stored in both quote and sales_order tables ultimately. This is something similar to adding an "order comment" field but this field should appear right after the shipping address section and before the shipping method section.



I went through Magento dev guides on how to add a custom field and a custom form to the checkout and implemented a solution to a certain extent.



What I have done so far:




  1. Updated the checkout_index_index.xml layout, added a new uiComponent (a container) under the item "shippingAddress".

  2. Added the element (field) I require inside the container.

  3. Override the /js/view/shipping.js and shipping.phtmlin my custom module.

  4. Invoked the above made container inside shipping.phtml in between checkout shipping address and shipping method (something similar to adding a new static form)


Now the field I want is being rendered on the onepage checkout exactly where I want. But I have met with below problems.





  1. How to access the value of the custom field I have added above? I'm trying to save the value to a shippingAddress extension attribute. I added a mixin to setShippingInformationAction inside that try to do the below



    shippingAddress['extension_attributes']['custom_field'] = shippingAddress.customAttributes['custom_field'];




But above code actually fails since the element is not in the shipping-address-fieldset. I might be able to get the value through the window element. But is there a way to access this through Magento?




  1. Is there a way to save the value of this element in local cache storage (Magento_Checkout/js/checkout-data) so the value will persist even after a page refresh?










share|improve this question
















bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    Take a look on this - magento.stackexchange.com/questions/135969/…

    – igloczek
    Aug 25 '17 at 22:08











  • Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

    – Pradeep Kumar
    Aug 29 '17 at 6:50


















17















I'm trying to add a custom field in between the shipping address and shipping method sections. And I want values of this field to be stored in both quote and sales_order tables ultimately. This is something similar to adding an "order comment" field but this field should appear right after the shipping address section and before the shipping method section.



I went through Magento dev guides on how to add a custom field and a custom form to the checkout and implemented a solution to a certain extent.



What I have done so far:




  1. Updated the checkout_index_index.xml layout, added a new uiComponent (a container) under the item "shippingAddress".

  2. Added the element (field) I require inside the container.

  3. Override the /js/view/shipping.js and shipping.phtmlin my custom module.

  4. Invoked the above made container inside shipping.phtml in between checkout shipping address and shipping method (something similar to adding a new static form)


Now the field I want is being rendered on the onepage checkout exactly where I want. But I have met with below problems.





  1. How to access the value of the custom field I have added above? I'm trying to save the value to a shippingAddress extension attribute. I added a mixin to setShippingInformationAction inside that try to do the below



    shippingAddress['extension_attributes']['custom_field'] = shippingAddress.customAttributes['custom_field'];




But above code actually fails since the element is not in the shipping-address-fieldset. I might be able to get the value through the window element. But is there a way to access this through Magento?




  1. Is there a way to save the value of this element in local cache storage (Magento_Checkout/js/checkout-data) so the value will persist even after a page refresh?










share|improve this question
















bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.











  • 2





    Take a look on this - magento.stackexchange.com/questions/135969/…

    – igloczek
    Aug 25 '17 at 22:08











  • Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

    – Pradeep Kumar
    Aug 29 '17 at 6:50














17












17








17


1






I'm trying to add a custom field in between the shipping address and shipping method sections. And I want values of this field to be stored in both quote and sales_order tables ultimately. This is something similar to adding an "order comment" field but this field should appear right after the shipping address section and before the shipping method section.



I went through Magento dev guides on how to add a custom field and a custom form to the checkout and implemented a solution to a certain extent.



What I have done so far:




  1. Updated the checkout_index_index.xml layout, added a new uiComponent (a container) under the item "shippingAddress".

  2. Added the element (field) I require inside the container.

  3. Override the /js/view/shipping.js and shipping.phtmlin my custom module.

  4. Invoked the above made container inside shipping.phtml in between checkout shipping address and shipping method (something similar to adding a new static form)


Now the field I want is being rendered on the onepage checkout exactly where I want. But I have met with below problems.





  1. How to access the value of the custom field I have added above? I'm trying to save the value to a shippingAddress extension attribute. I added a mixin to setShippingInformationAction inside that try to do the below



    shippingAddress['extension_attributes']['custom_field'] = shippingAddress.customAttributes['custom_field'];




But above code actually fails since the element is not in the shipping-address-fieldset. I might be able to get the value through the window element. But is there a way to access this through Magento?




  1. Is there a way to save the value of this element in local cache storage (Magento_Checkout/js/checkout-data) so the value will persist even after a page refresh?










share|improve this question
















I'm trying to add a custom field in between the shipping address and shipping method sections. And I want values of this field to be stored in both quote and sales_order tables ultimately. This is something similar to adding an "order comment" field but this field should appear right after the shipping address section and before the shipping method section.



I went through Magento dev guides on how to add a custom field and a custom form to the checkout and implemented a solution to a certain extent.



What I have done so far:




  1. Updated the checkout_index_index.xml layout, added a new uiComponent (a container) under the item "shippingAddress".

  2. Added the element (field) I require inside the container.

  3. Override the /js/view/shipping.js and shipping.phtmlin my custom module.

  4. Invoked the above made container inside shipping.phtml in between checkout shipping address and shipping method (something similar to adding a new static form)


Now the field I want is being rendered on the onepage checkout exactly where I want. But I have met with below problems.





  1. How to access the value of the custom field I have added above? I'm trying to save the value to a shippingAddress extension attribute. I added a mixin to setShippingInformationAction inside that try to do the below



    shippingAddress['extension_attributes']['custom_field'] = shippingAddress.customAttributes['custom_field'];




But above code actually fails since the element is not in the shipping-address-fieldset. I might be able to get the value through the window element. But is there a way to access this through Magento?




  1. Is there a way to save the value of this element in local cache storage (Magento_Checkout/js/checkout-data) so the value will persist even after a page refresh?







magento2 onepage-checkout custom-field






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Aug 6 '18 at 3:14









nikin

788315




788315










asked May 31 '17 at 20:52









ShanRShanR

153111




153111





bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.







bumped to the homepage by Community 5 mins ago


This question has answers that may be good or bad; the system has marked it active so that they can be reviewed.










  • 2





    Take a look on this - magento.stackexchange.com/questions/135969/…

    – igloczek
    Aug 25 '17 at 22:08











  • Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

    – Pradeep Kumar
    Aug 29 '17 at 6:50














  • 2





    Take a look on this - magento.stackexchange.com/questions/135969/…

    – igloczek
    Aug 25 '17 at 22:08











  • Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

    – Pradeep Kumar
    Aug 29 '17 at 6:50








2




2





Take a look on this - magento.stackexchange.com/questions/135969/…

– igloczek
Aug 25 '17 at 22:08





Take a look on this - magento.stackexchange.com/questions/135969/…

– igloczek
Aug 25 '17 at 22:08













Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

– Pradeep Kumar
Aug 29 '17 at 6:50





Please refer below link i hope it will help you magento.stackexchange.com/questions/187847/…

– Pradeep Kumar
Aug 29 '17 at 6:50










2 Answers
2






active

oldest

votes


















0














Based on your question I'm under the assumption you already have your extension attributes set up. I have carried out a similar modification and hopefully my answer helps.



In your Custom module create a requirejs-config file to extend the default shipping processor/default




Namespace/CustomModule/view/frontend/requirejs-config.js
var config = {
"map": {
"*": {
'Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default'
}
}
};


Add your extension attribute to the payload.




/*global define,alert*/
define(
[
'jquery',
'ko',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/resource-url-manager',
'mage/storage',
'Magento_Checkout/js/model/payment-service',
'Magento_Checkout/js/model/payment/method-converter',
'Magento_Checkout/js/model/error-processor',
'Magento_Checkout/js/model/full-screen-loader',
'Magento_Checkout/js/action/select-billing-address'
],
function (
$,
ko,
quote,
resourceUrlManager,
storage,
paymentService,
methodConverter,
errorProcessor,
fullScreenLoader,
selectBillingAddressAction
) {
'use strict';

return {
saveShippingInformation: function () {
var payload;

if (!quote.billingAddress()) {
selectBillingAddressAction(quote.shippingAddress());
}
//Adding the extension attributes to your shipping address
payload = {
addressInformation: {
shipping_address: quote.shippingAddress(),
billing_address: quote.billingAddress(),
shipping_method_code: quote.shippingMethod().method_code,
shipping_carrier_code: quote.shippingMethod().carrier_code,
extension_attributes:{
custom_field: $('#custom_field').val(),
}
}
};

fullScreenLoader.startLoader();

return storage.post(
resourceUrlManager.getUrlForSetShippingInformation(quote),
JSON.stringify(payload)
).done(
function (response) {
quote.setTotals(response.totals);
paymentService.setPaymentMethods(methodConverter(response.payment_methods));
fullScreenLoader.stopLoader();
}
).fail(
function (response) {
errorProcessor.process(response);
fullScreenLoader.stopLoader();
}
);
}
};
}
);



Save the Attribute to your Quote with a plugin (Not sure if you could use an observer here I have not checked).



di.xml



<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<type name="MagentoCheckoutModelShippingInformationManagement">
<plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="NamespaceCustomModulePluginCheckoutSaveAddressInformation" />
</type>

</config>


SaveAddressInformation.php




class SaveAddressInformation
{
protected $quoteRepository;
public function __construct(
MagentoQuoteModelQuoteRepository $quoteRepository
) {
$this->quoteRepository = $quoteRepository;
}
/**
* @param MagentoCheckoutModelShippingInformationManagement $subject
* @param $cartId
* @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
*/
public function beforeSaveAddressInformation(
MagentoCheckoutModelShippingInformationManagement $subject,
$cartId,
MagentoCheckoutApiDataShippingInformationInterface $addressInformation
) {
$extensionAttributes = $addressInformation->getExtensionAttributes();
$customField = $extensionAttributes->getCustomField();
$quote = $this->quoteRepository->getActive($cartId);
$quote->setCustomField($customField);

}
}


Save the Attribute to your order with an Observer
events.xml



<?xml version="1.0" encoding="UTF-8"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_before">
<observer name="unique_observer_name" instance="NamespaceCustomModuleObserverSaveCustomFieldToOrder"/>
</event>
</config>


SaveCustomFieldToOrder.php




class SaveCustomFieldToOrder implements ObserverInterface
{
/**
* @var MagentoFrameworkObjectManagerInterface
*/
protected $_objectManager;

/**
* @param MagentoFrameworkObjectManagerInterface $objectmanager
*/
public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)
{
$this->_objectManager = $objectmanager;
}

public function execute(EventObserver $observer)
{
$order = $observer->getOrder();
$quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
/** @var MagentoQuoteModelQuote $quote */
$quote = $quoteRepository->get($order->getQuoteId());
$order->setCustomField( $quote->getCustomField() );

return $this;
}
}






share|improve this answer
























  • Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

    – vaso123
    Mar 27 '18 at 20:21











  • good point, was not aware of the alternate method. thanks for pointing it out.

    – NathanielR
    Apr 11 '18 at 16:45











  • @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

    – Sarvagya
    Apr 25 '18 at 14:27













  • @Sarvagya When you use require js, do not use map *, use mixin instead.

    – vaso123
    Apr 25 '18 at 21:45











  • @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

    – NathanielR
    Apr 27 '18 at 11:05





















0














Create a plugin for this
MagentoCheckoutBlockCheckoutLayoutProcessor::process method.



Make an entry in di.xml on this path



app/code/CompanyName/Module/etc/frontend/di.xml








Create plugin class on this Directory.



app/code/CompanyNameModuleModelPluginCheckout








2 => Create plugin class on this Directory.
app/code/CompanyNameModuleModelPluginCheckout



    $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
'component' => 'Magento_Ui/js/form/element/abstract',
'config' => [
'customScope' => 'shippingAddress.custom_attributes',
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/input',
'options' => [],
'id' => 'custom-field'
],
'dataScope' => 'shippingAddress.custom_attributes.custom_field',
'label' => 'Custom Field',
'provider' => 'checkoutProvider',
'visible' => true,
'validation' => [],
'sortOrder' => 250,
'id' => 'custom-field'
];


return $jsLayout;
}


}



Once this is done, check the checkout page.






share|improve this answer


























    Your Answer








    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "479"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176878%2fmagento-2-checkout-add-a-custom-field-between-shipping-address-and-shipping-me%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    Based on your question I'm under the assumption you already have your extension attributes set up. I have carried out a similar modification and hopefully my answer helps.



    In your Custom module create a requirejs-config file to extend the default shipping processor/default




    Namespace/CustomModule/view/frontend/requirejs-config.js
    var config = {
    "map": {
    "*": {
    'Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default'
    }
    }
    };


    Add your extension attribute to the payload.




    /*global define,alert*/
    define(
    [
    'jquery',
    'ko',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/resource-url-manager',
    'mage/storage',
    'Magento_Checkout/js/model/payment-service',
    'Magento_Checkout/js/model/payment/method-converter',
    'Magento_Checkout/js/model/error-processor',
    'Magento_Checkout/js/model/full-screen-loader',
    'Magento_Checkout/js/action/select-billing-address'
    ],
    function (
    $,
    ko,
    quote,
    resourceUrlManager,
    storage,
    paymentService,
    methodConverter,
    errorProcessor,
    fullScreenLoader,
    selectBillingAddressAction
    ) {
    'use strict';

    return {
    saveShippingInformation: function () {
    var payload;

    if (!quote.billingAddress()) {
    selectBillingAddressAction(quote.shippingAddress());
    }
    //Adding the extension attributes to your shipping address
    payload = {
    addressInformation: {
    shipping_address: quote.shippingAddress(),
    billing_address: quote.billingAddress(),
    shipping_method_code: quote.shippingMethod().method_code,
    shipping_carrier_code: quote.shippingMethod().carrier_code,
    extension_attributes:{
    custom_field: $('#custom_field').val(),
    }
    }
    };

    fullScreenLoader.startLoader();

    return storage.post(
    resourceUrlManager.getUrlForSetShippingInformation(quote),
    JSON.stringify(payload)
    ).done(
    function (response) {
    quote.setTotals(response.totals);
    paymentService.setPaymentMethods(methodConverter(response.payment_methods));
    fullScreenLoader.stopLoader();
    }
    ).fail(
    function (response) {
    errorProcessor.process(response);
    fullScreenLoader.stopLoader();
    }
    );
    }
    };
    }
    );



    Save the Attribute to your Quote with a plugin (Not sure if you could use an observer here I have not checked).



    di.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="NamespaceCustomModulePluginCheckoutSaveAddressInformation" />
    </type>

    </config>


    SaveAddressInformation.php




    class SaveAddressInformation
    {
    protected $quoteRepository;
    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository
    ) {
    $this->quoteRepository = $quoteRepository;
    }
    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    ) {
    $extensionAttributes = $addressInformation->getExtensionAttributes();
    $customField = $extensionAttributes->getCustomField();
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setCustomField($customField);

    }
    }


    Save the Attribute to your order with an Observer
    events.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_before">
    <observer name="unique_observer_name" instance="NamespaceCustomModuleObserverSaveCustomFieldToOrder"/>
    </event>
    </config>


    SaveCustomFieldToOrder.php




    class SaveCustomFieldToOrder implements ObserverInterface
    {
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;

    /**
    * @param MagentoFrameworkObjectManagerInterface $objectmanager
    */
    public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)
    {
    $this->_objectManager = $objectmanager;
    }

    public function execute(EventObserver $observer)
    {
    $order = $observer->getOrder();
    $quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
    /** @var MagentoQuoteModelQuote $quote */
    $quote = $quoteRepository->get($order->getQuoteId());
    $order->setCustomField( $quote->getCustomField() );

    return $this;
    }
    }






    share|improve this answer
























    • Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

      – vaso123
      Mar 27 '18 at 20:21











    • good point, was not aware of the alternate method. thanks for pointing it out.

      – NathanielR
      Apr 11 '18 at 16:45











    • @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

      – Sarvagya
      Apr 25 '18 at 14:27













    • @Sarvagya When you use require js, do not use map *, use mixin instead.

      – vaso123
      Apr 25 '18 at 21:45











    • @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

      – NathanielR
      Apr 27 '18 at 11:05


















    0














    Based on your question I'm under the assumption you already have your extension attributes set up. I have carried out a similar modification and hopefully my answer helps.



    In your Custom module create a requirejs-config file to extend the default shipping processor/default




    Namespace/CustomModule/view/frontend/requirejs-config.js
    var config = {
    "map": {
    "*": {
    'Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default'
    }
    }
    };


    Add your extension attribute to the payload.




    /*global define,alert*/
    define(
    [
    'jquery',
    'ko',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/resource-url-manager',
    'mage/storage',
    'Magento_Checkout/js/model/payment-service',
    'Magento_Checkout/js/model/payment/method-converter',
    'Magento_Checkout/js/model/error-processor',
    'Magento_Checkout/js/model/full-screen-loader',
    'Magento_Checkout/js/action/select-billing-address'
    ],
    function (
    $,
    ko,
    quote,
    resourceUrlManager,
    storage,
    paymentService,
    methodConverter,
    errorProcessor,
    fullScreenLoader,
    selectBillingAddressAction
    ) {
    'use strict';

    return {
    saveShippingInformation: function () {
    var payload;

    if (!quote.billingAddress()) {
    selectBillingAddressAction(quote.shippingAddress());
    }
    //Adding the extension attributes to your shipping address
    payload = {
    addressInformation: {
    shipping_address: quote.shippingAddress(),
    billing_address: quote.billingAddress(),
    shipping_method_code: quote.shippingMethod().method_code,
    shipping_carrier_code: quote.shippingMethod().carrier_code,
    extension_attributes:{
    custom_field: $('#custom_field').val(),
    }
    }
    };

    fullScreenLoader.startLoader();

    return storage.post(
    resourceUrlManager.getUrlForSetShippingInformation(quote),
    JSON.stringify(payload)
    ).done(
    function (response) {
    quote.setTotals(response.totals);
    paymentService.setPaymentMethods(methodConverter(response.payment_methods));
    fullScreenLoader.stopLoader();
    }
    ).fail(
    function (response) {
    errorProcessor.process(response);
    fullScreenLoader.stopLoader();
    }
    );
    }
    };
    }
    );



    Save the Attribute to your Quote with a plugin (Not sure if you could use an observer here I have not checked).



    di.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="NamespaceCustomModulePluginCheckoutSaveAddressInformation" />
    </type>

    </config>


    SaveAddressInformation.php




    class SaveAddressInformation
    {
    protected $quoteRepository;
    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository
    ) {
    $this->quoteRepository = $quoteRepository;
    }
    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    ) {
    $extensionAttributes = $addressInformation->getExtensionAttributes();
    $customField = $extensionAttributes->getCustomField();
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setCustomField($customField);

    }
    }


    Save the Attribute to your order with an Observer
    events.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_before">
    <observer name="unique_observer_name" instance="NamespaceCustomModuleObserverSaveCustomFieldToOrder"/>
    </event>
    </config>


    SaveCustomFieldToOrder.php




    class SaveCustomFieldToOrder implements ObserverInterface
    {
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;

    /**
    * @param MagentoFrameworkObjectManagerInterface $objectmanager
    */
    public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)
    {
    $this->_objectManager = $objectmanager;
    }

    public function execute(EventObserver $observer)
    {
    $order = $observer->getOrder();
    $quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
    /** @var MagentoQuoteModelQuote $quote */
    $quote = $quoteRepository->get($order->getQuoteId());
    $order->setCustomField( $quote->getCustomField() );

    return $this;
    }
    }






    share|improve this answer
























    • Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

      – vaso123
      Mar 27 '18 at 20:21











    • good point, was not aware of the alternate method. thanks for pointing it out.

      – NathanielR
      Apr 11 '18 at 16:45











    • @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

      – Sarvagya
      Apr 25 '18 at 14:27













    • @Sarvagya When you use require js, do not use map *, use mixin instead.

      – vaso123
      Apr 25 '18 at 21:45











    • @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

      – NathanielR
      Apr 27 '18 at 11:05
















    0












    0








    0







    Based on your question I'm under the assumption you already have your extension attributes set up. I have carried out a similar modification and hopefully my answer helps.



    In your Custom module create a requirejs-config file to extend the default shipping processor/default




    Namespace/CustomModule/view/frontend/requirejs-config.js
    var config = {
    "map": {
    "*": {
    'Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default'
    }
    }
    };


    Add your extension attribute to the payload.




    /*global define,alert*/
    define(
    [
    'jquery',
    'ko',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/resource-url-manager',
    'mage/storage',
    'Magento_Checkout/js/model/payment-service',
    'Magento_Checkout/js/model/payment/method-converter',
    'Magento_Checkout/js/model/error-processor',
    'Magento_Checkout/js/model/full-screen-loader',
    'Magento_Checkout/js/action/select-billing-address'
    ],
    function (
    $,
    ko,
    quote,
    resourceUrlManager,
    storage,
    paymentService,
    methodConverter,
    errorProcessor,
    fullScreenLoader,
    selectBillingAddressAction
    ) {
    'use strict';

    return {
    saveShippingInformation: function () {
    var payload;

    if (!quote.billingAddress()) {
    selectBillingAddressAction(quote.shippingAddress());
    }
    //Adding the extension attributes to your shipping address
    payload = {
    addressInformation: {
    shipping_address: quote.shippingAddress(),
    billing_address: quote.billingAddress(),
    shipping_method_code: quote.shippingMethod().method_code,
    shipping_carrier_code: quote.shippingMethod().carrier_code,
    extension_attributes:{
    custom_field: $('#custom_field').val(),
    }
    }
    };

    fullScreenLoader.startLoader();

    return storage.post(
    resourceUrlManager.getUrlForSetShippingInformation(quote),
    JSON.stringify(payload)
    ).done(
    function (response) {
    quote.setTotals(response.totals);
    paymentService.setPaymentMethods(methodConverter(response.payment_methods));
    fullScreenLoader.stopLoader();
    }
    ).fail(
    function (response) {
    errorProcessor.process(response);
    fullScreenLoader.stopLoader();
    }
    );
    }
    };
    }
    );



    Save the Attribute to your Quote with a plugin (Not sure if you could use an observer here I have not checked).



    di.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="NamespaceCustomModulePluginCheckoutSaveAddressInformation" />
    </type>

    </config>


    SaveAddressInformation.php




    class SaveAddressInformation
    {
    protected $quoteRepository;
    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository
    ) {
    $this->quoteRepository = $quoteRepository;
    }
    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    ) {
    $extensionAttributes = $addressInformation->getExtensionAttributes();
    $customField = $extensionAttributes->getCustomField();
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setCustomField($customField);

    }
    }


    Save the Attribute to your order with an Observer
    events.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_before">
    <observer name="unique_observer_name" instance="NamespaceCustomModuleObserverSaveCustomFieldToOrder"/>
    </event>
    </config>


    SaveCustomFieldToOrder.php




    class SaveCustomFieldToOrder implements ObserverInterface
    {
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;

    /**
    * @param MagentoFrameworkObjectManagerInterface $objectmanager
    */
    public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)
    {
    $this->_objectManager = $objectmanager;
    }

    public function execute(EventObserver $observer)
    {
    $order = $observer->getOrder();
    $quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
    /** @var MagentoQuoteModelQuote $quote */
    $quote = $quoteRepository->get($order->getQuoteId());
    $order->setCustomField( $quote->getCustomField() );

    return $this;
    }
    }






    share|improve this answer













    Based on your question I'm under the assumption you already have your extension attributes set up. I have carried out a similar modification and hopefully my answer helps.



    In your Custom module create a requirejs-config file to extend the default shipping processor/default




    Namespace/CustomModule/view/frontend/requirejs-config.js
    var config = {
    "map": {
    "*": {
    'Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default'
    }
    }
    };


    Add your extension attribute to the payload.




    /*global define,alert*/
    define(
    [
    'jquery',
    'ko',
    'Magento_Checkout/js/model/quote',
    'Magento_Checkout/js/model/resource-url-manager',
    'mage/storage',
    'Magento_Checkout/js/model/payment-service',
    'Magento_Checkout/js/model/payment/method-converter',
    'Magento_Checkout/js/model/error-processor',
    'Magento_Checkout/js/model/full-screen-loader',
    'Magento_Checkout/js/action/select-billing-address'
    ],
    function (
    $,
    ko,
    quote,
    resourceUrlManager,
    storage,
    paymentService,
    methodConverter,
    errorProcessor,
    fullScreenLoader,
    selectBillingAddressAction
    ) {
    'use strict';

    return {
    saveShippingInformation: function () {
    var payload;

    if (!quote.billingAddress()) {
    selectBillingAddressAction(quote.shippingAddress());
    }
    //Adding the extension attributes to your shipping address
    payload = {
    addressInformation: {
    shipping_address: quote.shippingAddress(),
    billing_address: quote.billingAddress(),
    shipping_method_code: quote.shippingMethod().method_code,
    shipping_carrier_code: quote.shippingMethod().carrier_code,
    extension_attributes:{
    custom_field: $('#custom_field').val(),
    }
    }
    };

    fullScreenLoader.startLoader();

    return storage.post(
    resourceUrlManager.getUrlForSetShippingInformation(quote),
    JSON.stringify(payload)
    ).done(
    function (response) {
    quote.setTotals(response.totals);
    paymentService.setPaymentMethods(methodConverter(response.payment_methods));
    fullScreenLoader.stopLoader();
    }
    ).fail(
    function (response) {
    errorProcessor.process(response);
    fullScreenLoader.stopLoader();
    }
    );
    }
    };
    }
    );



    Save the Attribute to your Quote with a plugin (Not sure if you could use an observer here I have not checked).



    di.xml



    <?xml version="1.0"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <type name="MagentoCheckoutModelShippingInformationManagement">
    <plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="NamespaceCustomModulePluginCheckoutSaveAddressInformation" />
    </type>

    </config>


    SaveAddressInformation.php




    class SaveAddressInformation
    {
    protected $quoteRepository;
    public function __construct(
    MagentoQuoteModelQuoteRepository $quoteRepository
    ) {
    $this->quoteRepository = $quoteRepository;
    }
    /**
    * @param MagentoCheckoutModelShippingInformationManagement $subject
    * @param $cartId
    * @param MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    */
    public function beforeSaveAddressInformation(
    MagentoCheckoutModelShippingInformationManagement $subject,
    $cartId,
    MagentoCheckoutApiDataShippingInformationInterface $addressInformation
    ) {
    $extensionAttributes = $addressInformation->getExtensionAttributes();
    $customField = $extensionAttributes->getCustomField();
    $quote = $this->quoteRepository->getActive($cartId);
    $quote->setCustomField($customField);

    }
    }


    Save the Attribute to your order with an Observer
    events.xml



    <?xml version="1.0" encoding="UTF-8"?>
    <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
    <event name="sales_model_service_quote_submit_before">
    <observer name="unique_observer_name" instance="NamespaceCustomModuleObserverSaveCustomFieldToOrder"/>
    </event>
    </config>


    SaveCustomFieldToOrder.php




    class SaveCustomFieldToOrder implements ObserverInterface
    {
    /**
    * @var MagentoFrameworkObjectManagerInterface
    */
    protected $_objectManager;

    /**
    * @param MagentoFrameworkObjectManagerInterface $objectmanager
    */
    public function __construct(MagentoFrameworkObjectManagerInterface $objectmanager)
    {
    $this->_objectManager = $objectmanager;
    }

    public function execute(EventObserver $observer)
    {
    $order = $observer->getOrder();
    $quoteRepository = $this->_objectManager->create('MagentoQuoteModelQuoteRepository');
    /** @var MagentoQuoteModelQuote $quote */
    $quote = $quoteRepository->get($order->getQuoteId());
    $order->setCustomField( $quote->getCustomField() );

    return $this;
    }
    }







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Sep 18 '17 at 6:52









    NathanielRNathanielR

    33519




    33519













    • Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

      – vaso123
      Mar 27 '18 at 20:21











    • good point, was not aware of the alternate method. thanks for pointing it out.

      – NathanielR
      Apr 11 '18 at 16:45











    • @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

      – Sarvagya
      Apr 25 '18 at 14:27













    • @Sarvagya When you use require js, do not use map *, use mixin instead.

      – vaso123
      Apr 25 '18 at 21:45











    • @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

      – NathanielR
      Apr 27 '18 at 11:05





















    • Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

      – vaso123
      Mar 27 '18 at 20:21











    • good point, was not aware of the alternate method. thanks for pointing it out.

      – NathanielR
      Apr 11 '18 at 16:45











    • @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

      – Sarvagya
      Apr 25 '18 at 14:27













    • @Sarvagya When you use require js, do not use map *, use mixin instead.

      – vaso123
      Apr 25 '18 at 21:45











    • @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

      – NathanielR
      Apr 27 '18 at 11:05



















    Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

    – vaso123
    Mar 27 '18 at 20:21





    Overriding core methods is not too lucky. What if another module override yours? magento.stackexchange.com/questions/135969/…

    – vaso123
    Mar 27 '18 at 20:21













    good point, was not aware of the alternate method. thanks for pointing it out.

    – NathanielR
    Apr 11 '18 at 16:45





    good point, was not aware of the alternate method. thanks for pointing it out.

    – NathanielR
    Apr 11 '18 at 16:45













    @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

    – Sarvagya
    Apr 25 '18 at 14:27







    @vaso123 It looks like I am also not aware of something because here Nathaniel has created a plugin and one event-observer so which core function is overriden here. Could you please explain it little more, it would be really helpful ... Thanks

    – Sarvagya
    Apr 25 '18 at 14:27















    @Sarvagya When you use require js, do not use map *, use mixin instead.

    – vaso123
    Apr 25 '18 at 21:45





    @Sarvagya When you use require js, do not use map *, use mixin instead.

    – vaso123
    Apr 25 '18 at 21:45













    @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

    – NathanielR
    Apr 27 '18 at 11:05







    @vaso123 I believe he is referring to Magento_Checkout/js/model/shipping-save-processor/default': 'Namespace_CustomModule/js/model/shipping-save-processor/default' which as Ii understand replaces Magento_Checkout/js/model/shipping-save-processor/default. } its been a while since I wrote this so Sarvagya please correct me if I'm wrong.

    – NathanielR
    Apr 27 '18 at 11:05















    0














    Create a plugin for this
    MagentoCheckoutBlockCheckoutLayoutProcessor::process method.



    Make an entry in di.xml on this path



    app/code/CompanyName/Module/etc/frontend/di.xml








    Create plugin class on this Directory.



    app/code/CompanyNameModuleModelPluginCheckout








    2 => Create plugin class on this Directory.
    app/code/CompanyNameModuleModelPluginCheckout



        $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
    ['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
    'component' => 'Magento_Ui/js/form/element/abstract',
    'config' => [
    'customScope' => 'shippingAddress.custom_attributes',
    'template' => 'ui/form/field',
    'elementTmpl' => 'ui/form/element/input',
    'options' => [],
    'id' => 'custom-field'
    ],
    'dataScope' => 'shippingAddress.custom_attributes.custom_field',
    'label' => 'Custom Field',
    'provider' => 'checkoutProvider',
    'visible' => true,
    'validation' => [],
    'sortOrder' => 250,
    'id' => 'custom-field'
    ];


    return $jsLayout;
    }


    }



    Once this is done, check the checkout page.






    share|improve this answer






























      0














      Create a plugin for this
      MagentoCheckoutBlockCheckoutLayoutProcessor::process method.



      Make an entry in di.xml on this path



      app/code/CompanyName/Module/etc/frontend/di.xml








      Create plugin class on this Directory.



      app/code/CompanyNameModuleModelPluginCheckout








      2 => Create plugin class on this Directory.
      app/code/CompanyNameModuleModelPluginCheckout



          $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
      ['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
      'component' => 'Magento_Ui/js/form/element/abstract',
      'config' => [
      'customScope' => 'shippingAddress.custom_attributes',
      'template' => 'ui/form/field',
      'elementTmpl' => 'ui/form/element/input',
      'options' => [],
      'id' => 'custom-field'
      ],
      'dataScope' => 'shippingAddress.custom_attributes.custom_field',
      'label' => 'Custom Field',
      'provider' => 'checkoutProvider',
      'visible' => true,
      'validation' => [],
      'sortOrder' => 250,
      'id' => 'custom-field'
      ];


      return $jsLayout;
      }


      }



      Once this is done, check the checkout page.






      share|improve this answer




























        0












        0








        0







        Create a plugin for this
        MagentoCheckoutBlockCheckoutLayoutProcessor::process method.



        Make an entry in di.xml on this path



        app/code/CompanyName/Module/etc/frontend/di.xml








        Create plugin class on this Directory.



        app/code/CompanyNameModuleModelPluginCheckout








        2 => Create plugin class on this Directory.
        app/code/CompanyNameModuleModelPluginCheckout



            $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
        'component' => 'Magento_Ui/js/form/element/abstract',
        'config' => [
        'customScope' => 'shippingAddress.custom_attributes',
        'template' => 'ui/form/field',
        'elementTmpl' => 'ui/form/element/input',
        'options' => [],
        'id' => 'custom-field'
        ],
        'dataScope' => 'shippingAddress.custom_attributes.custom_field',
        'label' => 'Custom Field',
        'provider' => 'checkoutProvider',
        'visible' => true,
        'validation' => [],
        'sortOrder' => 250,
        'id' => 'custom-field'
        ];


        return $jsLayout;
        }


        }



        Once this is done, check the checkout page.






        share|improve this answer















        Create a plugin for this
        MagentoCheckoutBlockCheckoutLayoutProcessor::process method.



        Make an entry in di.xml on this path



        app/code/CompanyName/Module/etc/frontend/di.xml








        Create plugin class on this Directory.



        app/code/CompanyNameModuleModelPluginCheckout








        2 => Create plugin class on this Directory.
        app/code/CompanyNameModuleModelPluginCheckout



            $jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']
        ['shippingAddress']['children']['shipping-address-fieldset']['children']['custom_field'] = [
        'component' => 'Magento_Ui/js/form/element/abstract',
        'config' => [
        'customScope' => 'shippingAddress.custom_attributes',
        'template' => 'ui/form/field',
        'elementTmpl' => 'ui/form/element/input',
        'options' => [],
        'id' => 'custom-field'
        ],
        'dataScope' => 'shippingAddress.custom_attributes.custom_field',
        'label' => 'Custom Field',
        'provider' => 'checkoutProvider',
        'visible' => true,
        'validation' => [],
        'sortOrder' => 250,
        'id' => 'custom-field'
        ];


        return $jsLayout;
        }


        }



        Once this is done, check the checkout page.







        share|improve this answer














        share|improve this answer



        share|improve this answer








        edited Sep 14 '18 at 7:41









        Rama Chandran M

        2,74181530




        2,74181530










        answered Sep 14 '18 at 7:24









        BandiniBandini

        62




        62






























            draft saved

            draft discarded




















































            Thanks for contributing an answer to Magento Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fmagento.stackexchange.com%2fquestions%2f176878%2fmagento-2-checkout-add-a-custom-field-between-shipping-address-and-shipping-me%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            “%fieldName is a required field.”, in Magento2 REST API Call for GET Method Type The Next...

            How to change City field to a dropdown in Checkout step Magento 2Magento 2 : How to change UI field(s)...

            夢乃愛華...