是的,可以通过更改Magento_Checkout / js / model / shipping-save-processor / default.js来实现
我在结帐时添加了confirm email
必须与email
必填字段相同的字段,您可以根据需要自定义。
app\code\Ketan\Checkout\view\frontend\requirejs-config.js
var config = {
"map": {
"*": {
"Magento_Checkout/js/model/shipping-save-processor/default" : "Ketan_Checkout/js/shipping-save-processor"
}
}
}
扩展js file app\code\Ketan\Checkout\view\frontend\web\js\shipping-save-processor.js
/*
* *
* @author DCKAP Team
* @copyright Copyright (c) 2018 DCKAP (https://www.dckap.com)
* @package Dckap_CustomFields
*/
define(
[
'ko',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/model/resource-url-manager',
'mage/storage',
'Magento_Checkout/js/model/payment-service',
'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',
'jquery'
],
function (
ko,
quote,
resourceUrlManager,
storage,
paymentService,
methodConverter,
errorProcessor,
fullScreenLoader,
selectBillingAddressAction,
$
) {
'use strict';
return {
saveShippingInformation: function () {
var payload;
var username = $("#customer-email").val();
var conformusername = $("#conformusername").val();
/*============ Customization Start =============*/
//if(quote.shippingMethod().method_code=='flaterate'){ // Check if flaterate is selected
if(conformusername != username){
$("#conformusername-error").show(); // show hidden message
$("#conformusername").focus(); // move cursor to the point
return false;
}
// }
/*============ Customization End =============*/
if (!quote.billingAddress()) {
selectBillingAddressAction(quote.shippingAddress());
}
payload = {
addressInformation: {
shipping_address: quote.shippingAddress(),
billing_address: quote.billingAddress(),
shipping_method_code: quote.shippingMethod().method_code,
shipping_carrier_code: quote.shippingMethod().carrier_code
}
};
fullScreenLoader.startLoader();
return storage.post(
resourceUrlManager.getUrlForSetShippingInformation(quote),
JSON.stringify(payload)
).done(
function (response) {
quote.setTotals(response.totals);
paymentService.setPaymentMethods(methodConverter(response.payment_methods));
fullScreenLoader.stopLoader();
}
).fail(
function (response) {
errorProcessor.process(response);
fullScreenLoader.stopLoader();
}
);
}
};
}
);