Berdasarkan pertanyaan Anda, saya berasumsi Anda sudah menyiapkan atribut ekstensi. Saya telah melakukan modifikasi serupa dan semoga jawaban saya membantu.
Dalam modul Kustom Anda buat file requirejs-config untuk memperpanjang prosesor pengiriman default / default
Namespace / CustomModule / view / frontend / requireejs-config.js
var config = {
"map": {
"*": {
'Magento_Checkout / js / model / pengiriman-save-processor / default': 'Namespace_CustomModule / js / model / pengiriman-save-processor / default'
}
}
};
Tambahkan atribut ekstensi Anda ke payload.
/ * global define, waspada * /
menetapkan(
[
'jquery',
'ko',
'Magento_Checkout / js / model / quote',
'Magento_Checkout / js / model / resource-url-manager',
'penyihir / penyimpanan',
'Magento_Checkout / js / model / layanan pembayaran',
'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'
],
fungsi (
$,
ko,
mengutip,
resourceUrlManager,
penyimpanan,
layanan pembayaran,
metodeConverter,
pengolah kesalahan,
fullScreenLoader,
pilihBillingAddressAction
) {
'gunakan yang ketat';
kembali {
saveShippingInformation: function () {
var payload;
if (! quote.billingAddress ()) {
selectBillingAddressAction (quote.shippingAddress ());
}
// Menambahkan atribut ekstensi ke alamat pengiriman Anda
payload = {
Informasi alamat: {
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)
). dilakukan (
fungsi (respons) {
quote.setTotals (response.totals);
paymentService.setPaymentMethods (methodConverter (response.payment_methods));
fullScreenLoader.stopLoader ();
}
).gagal(
fungsi (respons) {
errorProcessor.process (response);
fullScreenLoader.stopLoader ();
}
);
}
};
}
);
Simpan Atribut ke Kutipan Anda dengan sebuah plugin (Tidak yakin apakah Anda bisa menggunakan pengamat di sini yang belum saya periksa).
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="Magento\Checkout\Model\ShippingInformationManagement">
<plugin name="Namespace_CustomModule_save_delivery_date_in_quote" type="Namespace\CustomModule\Plugin\Checkout\SaveAddressInformation" />
</type>
</config>
SaveAddressInformation.php
kelas SaveAddressInformation
{
protected $ quoteRepository;
fungsi publik __construct (
\ Magento \ Penawaran \ Model \ QuoteRepository $ quoteRepository
) {
$ this-> quoteRepository = $ quoteRepository;
}
/ **
* @param \ Magento \ Checkout \ Model \ ShippingInformationManagement $ subject
* @param $ cartId
* @param \ Magento \ Checkout \ Api \ Data \ ShippingInformationInterface $ addressInformation
* /
fungsi publik sebelumSimpanAddressInformation (
\ Magento \ Checkout \ Model \ ShippingInformationManagement $ subjek,
$ cartId,
\ Magento \ Checkout \ Api \ Data \ ShippingInformationInterface $ addressInformation
) {
$ extensionAttributes = $ addressInformation-> getExtensionAttributes ();
$ customField = $ extensionAttributes-> getCustomField ();
$ quote = $ this-> quoteRepository-> getActive ($ cartId);
$ quote-> setCustomField ($ customField);
}
}
Simpan atribut ke pesanan Anda dengan 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="Namespace\CustomModule\Observer\SaveCustomFieldToOrder"/>
</event>
</config>
SaveCustomFieldToOrder.php
class SaveCustomFieldToOrder mengimplementasikan ObserverInterface
{
/ **
* @var \ Magento \ Framework \ ObjectManagerInterface
* /
protected $ _objectManager;
/ **
* @param \ Magento \ Framework \ ObjectManagerInterface $ objectmanager
* /
fungsi publik __construct (\ Magento \ Framework \ ObjectManagerInterface $ objectmanager)
{
$ this -> _ objectManager = $ objectmanager;
}
mengeksekusi fungsi publik (EventObserver $ observer)
{
$ order = $ observer-> getOrder ();
$ quoteRepository = $ this -> _ objectManager-> create ('Magento \ Quote \ Model \ QuoteRepository');
/ ** @var \ Magento \ Penawaran \ Model \ Penawaran $ quote * /
$ quote = $ quoteRepository-> get ($ order-> getQuoteId ());
$ order-> setCustomField ($ quote-> getCustomField ());
mengembalikan $ this;
}
}