Feedback on page: /guides/v2.1/howdoi/checkout/checkout_new_field.html
Where to setup this part to verify data exist ?
$value = $address->getExtensionAttributes()->getCustomField();
Copy
Hey @irenelagno - This is regarding the last section of https://devdocs.magento.com//guides/v2.1/howdoi/checkout/checkout_new_field.html. Can you help us out with this? Thanks!
Hey @gelanivishal - Do you have info on this? Thanks in advance!
@shrielenee Depends on business logic. You can add plugins on api calls which uses on checkout to verify if data exists. For example
'guest': '/guest-carts/:cartId/shipping-information',
'customer': '/carts/mine/shipping-information'
@shrielenee @terryx
After perform this Step 4: Add field to address model step,
Now clear the var/generation when you run setup:di:compile command, new getter and setter methods will be added in /var/generation/Magento/Checkout/Api/Data/ShippingInformationExtensionInterface.php
Now you can set/get these attributes value by creating the instance of Magento/Checkout/Api/Data/ShippingInformationInterface.php interface.
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$addressInformation = $objectManager->create('Magento\Checkout\Api\Data\ShippingInformationInterface');
$extAttributes = $addressInformation->getExtensionAttributes();
$selectedShipping = $extAttributes->getCustomShippingCharge(); //get custom attribute data.
I also give you an reference link which help to you.
Referece Link: https://www.zynovo.com/blog/magento-2-extension-attributes/
Note: I have used here $objectManager for your reference but It's not good practice.
Thank you.
Thanks @gelanivishal! Can you implement these changes in the docs and push up a PR for review? @jcalcaben can then approve or request changes, and facilitate merging, as needed. 馃弳
@shrielenee Let me create a PR for it.