Define the extension attribute in XML
app/code/Vendor/Module/etc/extension_attributes.xml
1 2 3 4 5 6 |
<?xml version="1.0"?> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd"> <extension_attributes for="Magento\Checkout\Api\Data\ShippingInformationInterface"> <attribute code="address_two" type="string"/> </extension_attributes> </config> |
Assigning the value for extension attributes in knockout js
app/code/Vendor/Module/view/frontend/web/js/shipping-save-processor-default.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
saveShippingInformation: function () { var payload; 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: { address_two: $('form.form-shipping-address input[name="address2"]').val() } } }; return storage.post( resourceUrlManager.getUrlForSetShippingInformation(quote), JSON.stringify(payload) ).done( function (response) { quote.setTotals(response.totals); paymentService.setPaymentMethods(methodConverter(response.payment_methods)); } ).fail( function (response) { errorProcessor.process(response); } ); } |
Save Extension Attribute to quote table using beforeSaveAddressInformation method using Plugin
app/code/Vendor/Module/Model/Checkout/ShippingInformationManagementPlugin.php
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
namespace Vendor\Module\Model\Checkout; /** * Class ShippingInformationManagementPlugin * @package Oye\Deliverydate\Model\Checkout */ class ShippingInformationManagementPlugin { protected $quoteRepository; /** * @param \Magento\Quote\Model\QuoteRepository $quoteRepository */ public function __construct( \Magento\Quote\Model\QuoteRepository $quoteRepository ) { $this->quoteRepository = $quoteRepository; } /** * @param \Magento\Checkout\Model\ShippingInformationManagement $subject * @param $cartId * @param \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation */ public function beforeSaveAddressInformation( \Magento\Checkout\Model\ShippingInformationManagement $subject, $cartId, \Magento\Checkout\Api\Data\ShippingInformationInterface $addressInformation ) { $extAttributes = $addressInformation->getExtensionAttributes(); $address2=$extAttributes->getAddressTwo(); $quote = $this->quoteRepository->getActive($cartId); $quote->setShippingAddressTwo($shippngaddress2); $this->quoteRepository->save($quote);; } } |
CONTACT US to get Magento programming solutions by hiring a certified Magento expert.
If you want get query string params in controller file,...
Create di.xml and add the below code Magemonkey/Redirect/etc/frontend/di.xml [crayon-628766caee146702940016/] Create...
You can try below code to change local date to...
Step 1: First you need to add registration.php file in...
Step1 : Override message.js in current theme file on the...