Skip to content

Commit

Permalink
Merge pull request #44 from bold-commerce/INTER-4355
Browse files Browse the repository at this point in the history
Incorrect Fastlane Address List Rendering on Magento 2.3.5
  • Loading branch information
NickolasMalovanets authored Jul 29, 2024
2 parents 67a6e6a + 737f172 commit c5bccc2
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 19 deletions.
15 changes: 11 additions & 4 deletions view/frontend/web/js/action/reset-shipping-address.js
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
define(
[
'Magento_Customer/js/model/address-list',
'Magento_Checkout/js/model/quote',
'Bold_CheckoutPaymentBooster/js/action/show-shipping-address-form'
], function (
addressList,
showShippingAddressForm
quote,
showShippingAddressForm,
) {
'use strict';

/**
* Remove shipping address from quote and show new shipping address form action.
*/
return function () {
addressList([]);
const quoteShippingAddress = quote.shippingAddress();
if (quoteShippingAddress.getType() !== 'fastlane-shipping-address') {
return;
}
quoteShippingAddress.getType = function () {
return 'new-customer-address';
};
quote.shippingAddress(quoteShippingAddress);
showShippingAddressForm();
};
});
2 changes: 1 addition & 1 deletion view/frontend/web/js/action/set-quote-shipping-address.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ define(
*/
return function (fastlaneAddress) {
const shippingAddress = convertFastlaneAddressAction(fastlaneAddress);
addressList([shippingAddress]);
addressList([]);
selectShippingAddressAction(shippingAddress);
checkoutData.setSelectedShippingAddress(shippingAddress.getKey());
hideShippingAddressFormAction();
Expand Down
3 changes: 3 additions & 0 deletions view/frontend/web/js/action/show-shipping-address-form.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ define(
*/
return function () {
const newShippingAddress = registry.get('index = shippingAddress');
if (!newShippingAddress) {
return;
}
const newShippingAddressFieldset = newShippingAddress.getChild('shipping-address-fieldset');
newShippingAddress.isFormInline = true;
if (!newShippingAddressFieldset) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,6 @@ define(
}
this.lookupEmail().then(() => {
fullScreenLoader.stopLoader();
this.isPasswordVisible(false);
}).catch((error) => {
fullScreenLoader.stopLoader();
console.log(error);
Expand Down Expand Up @@ -105,6 +104,7 @@ define(
window.checkoutConfig.bold.fastlane.profileData = profileData;
fullScreenLoader.startLoader();
this.setShippingAddress(profileData);
this.isPasswordVisible(false);
}
return;
}
Expand Down
27 changes: 14 additions & 13 deletions view/frontend/web/js/view/shipping-address/list.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ define(
'Magento_Customer/js/model/address-list',
'Bold_CheckoutPaymentBooster/js/action/show-shipping-address-form',
'Bold_CheckoutPaymentBooster/js/model/fastlane',
'Magento_Checkout/js/model/quote'
],
function (
ko,
shippingAddressList,
customerAddressList,
showShippingAddressFormAction,
fastlane
fastlane,
quote
) {
'use strict';

Expand All @@ -38,22 +40,21 @@ define(
this.visible(false);
return;
}
customerAddressList.subscribe(function (changes) {
let self = this;
changes.forEach(function (change) {
if (change.status === 'deleted' && customerAddressList().length === 0) {
self.visible(false);
showShippingAddressFormAction();
}
});
},
this,
'arrayChange'
);
quote.shippingAddress.subscribe(function (address) {
if (address && address.getType() === 'fastlane-shipping-address') {
this.createRendererComponent(address, 0);
return;
}
this.visible(false);
showShippingAddressFormAction();
}.bind(this));
},

/** @inheritdoc */
createRendererComponent: function (address, index) {
if (address.getType() !== 'fastlane-shipping-address') {
return;
}
this._super(address, index);
if (!fastlane.isEnabled()) {
this.visible(false);
Expand Down

0 comments on commit c5bccc2

Please sign in to comment.