I’ve followed the instructions by creating a custom extension in the following link :
https://magento.stackexchange.com/a/361986/105485
It’s works fine, but I need it to be unchecked only when customer select store pickup.
Could you please help me with this ?
My “checkout-data-resolver-mixin.js” file:
define([
'mage/utils/wrapper',
'Magento_Customer/js/model/address-list',
'Magento_Checkout/js/model/quote',
'Magento_Checkout/js/action/select-billing-address'
], function (
wrapper,
addressList,
quote,
selectBillingAddress
) {
'use strict';
return function (checkoutDataResolver) {
// Customize: Remove feature set billing address same as shipping by default
checkoutDataResolver.applyBillingAddress = wrapper.wrapSuper(
checkoutDataResolver.applyBillingAddress, function () {
if (quote.billingAddress()) {
selectBillingAddress(quote.billingAddress());
return;
}
// The below code select default billing address as billing address
if (quote.isVirtual() || !quote.billingAddress()) {
addressList.some(function (addrs) {
if (addrs.isDefaultBilling()) {
selectBillingAddress(addrs);
return true;
}
return false;
});
}
}
);
return checkoutDataResolver;
};
});
My “default.js” file:
/**
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
/**
* This file override Magento_Checkout::js/model/shipping-save-processor/default.js
* Customize: Remove feature set billing address same as shipping by default
* Updated to magento version 2.4.5-p1
*/
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',
'Magento_Checkout/js/model/shipping-save-processor/payload-extender'
], function (
ko,
quote,
resourceUrlManager,
storage,
paymentService,
methodConverter,
errorProcessor,
fullScreenLoader,
selectBillingAddressAction,
payloadExtender
) {
'use strict';
return {
/**
* Customize: Remove feature set billing address same as shipping by default
* @return {jQuery.Deferred}
*/
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']
}
};
payloadExtender(payload);
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();
}
);
}
};
});
Thanks in advance.