I have an extension attribute on quote address called "subdistrict". The data is successfuly saved to quote_address. But when completing the order, these data are not saved to sales_order_address.
below is my fieldset.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:DataObject/etc/fieldset.xsd">
<scope id="global">
<fieldset id="sales_convert_quote_address">
<field name="subdistrict">
<aspect name="to_order_address" />
</field>
</fieldset>
</scope>
and my extensions_attributes.xml
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Api/etc/extension_attributes.xsd">
<extension_attributes for="Magento\Quote\Api\Data\AddressInterface">
<attribute code="subdistrict" type="string" />
</extension_attributes>
<extension_attributes for="Magento\Sales\Api\Data\OrderAddressInterface">
<attribute code="subdistrict" type="string" />
</extension_attributes>
right now i am getting an error:
"Error occurred during "shipping_address" processing. Error occurred during "extension_attributes" processing. Error occurred during "subdistrict" processing. Invalid type for value: "array". Expected Type: "string"."
and here is some part of the quote content:
["city"]=>
string(14) "Kab. Tangerang"
["firstname"]=>
string(7) "Yohanes"
["lastname"]=>
string(7) "Pradono"
["customAttributes"]=>
array(1) {
["subdistrict"]=>
array(2) {
["attribute_code"]=>
string(11) "subdistrict"
["value"]=>
string(8) "Balaraja"
}
}
["extension_attributes"]=>
array(1) {
["subdistrict"]=>
array(2) {
["attribute_code"]=>
string(11) "subdistrict"
["value"]=>
string(8) "Balaraja"
}
}
["same_as_billing"]=>
and my mixin.js
define([
'jquery',
'mage/utils/wrapper',
'Magento_Checkout/js/model/quote'
], function ($, wrapper, quote) {
'use strict';
return function (setShippingInformationAction) {
return wrapper.wrap(setShippingInformationAction, function (originalAction) {
var shippingAddress = quote.shippingAddress();
if (shippingAddress['extension_attributes'] === undefined) {
shippingAddress['extension_attributes'] = {};
}
// you can extract value of extension attribute from any place (in this example I use custom_attributes approach)
// Don: the actual data to be sent to Magento backend is inside 'extension_attributes'
console.log(shippingAddress);
shippingAddress['extension_attributes']['subdistrict'] = shippingAddress.customAttributes['subdistrict'];
// pass execution to original action ('Magento_Checkout/js/action/set-shipping-information')
return originalAction();
});
};
});