Magento 2: Update payment methods on change billing address from existing billing options [closed]
-
13-04-2021 - |
Domanda
How to update payment methods on change billing address from existing billing options Magento 2 ?
Soluzione
Use this.updateAddresses()
function
in
updateAddress: function () {
var addressData, newBillingAddress;
if (this.selectedAddress() && !this.isAddressFormVisible()) {
selectBillingAddress(this.selectedAddress());
checkoutData.setSelectedBillingAddress(this.selectedAddress().getKey());
this.updateAddresses();
} else {
this.source.set('params.invalid', false);
this.source.trigger(this.dataScopePrefix + '.data.validate');
if (this.source.get(this.dataScopePrefix + '.custom_attributes')) {
this.source.trigger(this.dataScopePrefix + '.custom_attributes.data.validate');
}
if (!this.source.get('params.invalid')) {
addressData = this.source.get(this.dataScopePrefix);
if (customer.isLoggedIn() && !this.customerHasAddresses) { //eslint-disable-line max-depth
this.saveInAddressBook(1);
}
addressData['save_in_address_book'] = this.saveInAddressBook() ? 1 : 0;
newBillingAddress = createBillingAddress(addressData);
// New address must be selected as a billing address
selectBillingAddress(newBillingAddress);
checkoutData.setSelectedBillingAddress(newBillingAddress.getKey());
checkoutData.setNewCustomerBillingAddress(addressData);
}
}
In view/billing-address.js
file to update address on change billing address.
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a magento.stackexchange