I am overriding shipping address in mixin js file , I want id in my controller when we move from checkout page next step.
/jshint browser:true jquery:true/
/global alert/
define([
‘jquery’,
‘mage/utils/wrapper’,
‘mage/storage’,
‘uiComponent’,
‘Magento_Checkout/js/model/quote’
], function ($, wrapper, storage,Component, quote) {
‘use strict’;
return function (setShippingInformationAction) {
return wrapper.wrap(setShippingInformationAction, function (originalAction) {
var shippingAddress = quote.shippingAddress();
console.log("Before");
console.log(shippingAddress);
var countryId = quote.shippingAddress().countryId;
if (shippingAddress['extension_attributes'] === undefined) {
shippingAddress['extension_attributes'] = {};
}
var attribute1 = shippingAddress.customAttributes.find(
function (element) {
return element.attribute_code === 'eventid';
}
);
var attribute = shippingAddress.customAttributes.find(
function (element) {
return element.attribute_code === 'custom_field';
}
);
shippingAddress['extension_attributes']['custom_field'] = attribute.value;
shippingAddress['extension_attributes']['eventid'] = attribute1.value;
// ajax call
var param = 'ajax=1';
$.ajax({
showLoader: true,
url: 'http://127.0.0.1/magento237new/test2.php',
data: {eventid: attribute1.value},
type: "POST",
dataType: 'json'
}).done(function (data) {
console.log(data);
});
console.log("After");
console.log(shippingAddress);
return originalAction(); //
});
};
});