You could do the following:
- overwrite a default js file checkout-data-resolver.js
- add extra lines to the applyBillingAddress function to check if default
billing address exists and if true to use it
step 1. Overwritting a default magento checkout-data-resolver.js
with following content
var config = {
map: {
'*': {
'Magento_Checkout/js/model/checkout-data-resolver':
'YourCompany_Checkout/js/model/checkout-data-resolver'
}
}
};
- 1.3 Copy magento file \vendor\magento\module-checkout\view\frontend\web\js\model\checkout-data-resolver.js
to the destination
\app\code\YourCompany\Checkout\view\frontend\web\js\model\checkout-data-resolver.js
step 2. Modify applyBillingAddress function
2.1 in new checkout-data-resolver.js file find applyBillingAddress. Insert following cod after var shippingAddress;
and before if (quote.billingAddress())
....
var isBillingAddressInitialized;
isBillingAddressInitialized = addressList.some(function (addressFromList) {
if (addressFromList.isDefaultBilling()) {
selectBillingAddress(addressFromList);
return true;
}
return false;
});
if(isBillingAddressInitialized){
return;
}
....
This code actually goes through customer addresses and checks if any of them has defaultBilling set to true. If such an address exists it will be used as the billing address. If not the script will fall back to the default magento behavior