From 737f1722419dc2e28b9f293b0d27745f1c76dc8d Mon Sep 17 00:00:00 2001 From: Nickolas Malovanets Date: Mon, 29 Jul 2024 14:47:36 +0300 Subject: [PATCH] Incorrect Fastlane Address List Rendering on Magento 2.3.5 --- .../web/js/action/reset-shipping-address.js | 15 ++++++++--- .../js/action/set-quote-shipping-address.js | 2 +- .../js/action/show-shipping-address-form.js | 3 +++ .../view/form/element/email/fastlane-mixin.js | 2 +- .../web/js/view/shipping-address/list.js | 27 ++++++++++--------- 5 files changed, 30 insertions(+), 19 deletions(-) diff --git a/view/frontend/web/js/action/reset-shipping-address.js b/view/frontend/web/js/action/reset-shipping-address.js index 8f6f8a2..f04fe5f 100644 --- a/view/frontend/web/js/action/reset-shipping-address.js +++ b/view/frontend/web/js/action/reset-shipping-address.js @@ -1,10 +1,10 @@ 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'; @@ -12,7 +12,14 @@ define( * 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(); }; }); diff --git a/view/frontend/web/js/action/set-quote-shipping-address.js b/view/frontend/web/js/action/set-quote-shipping-address.js index d799ef7..5f6924e 100644 --- a/view/frontend/web/js/action/set-quote-shipping-address.js +++ b/view/frontend/web/js/action/set-quote-shipping-address.js @@ -22,7 +22,7 @@ define( */ return function (fastlaneAddress) { const shippingAddress = convertFastlaneAddressAction(fastlaneAddress); - addressList([shippingAddress]); + addressList([]); selectShippingAddressAction(shippingAddress); checkoutData.setSelectedShippingAddress(shippingAddress.getKey()); hideShippingAddressFormAction(); diff --git a/view/frontend/web/js/action/show-shipping-address-form.js b/view/frontend/web/js/action/show-shipping-address-form.js index 89bd886..559a30b 100644 --- a/view/frontend/web/js/action/show-shipping-address-form.js +++ b/view/frontend/web/js/action/show-shipping-address-form.js @@ -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) { diff --git a/view/frontend/web/js/view/form/element/email/fastlane-mixin.js b/view/frontend/web/js/view/form/element/email/fastlane-mixin.js index 7e8ec36..2871e94 100644 --- a/view/frontend/web/js/view/form/element/email/fastlane-mixin.js +++ b/view/frontend/web/js/view/form/element/email/fastlane-mixin.js @@ -71,7 +71,6 @@ define( } this.lookupEmail().then(() => { fullScreenLoader.stopLoader(); - this.isPasswordVisible(false); }).catch((error) => { fullScreenLoader.stopLoader(); console.log(error); @@ -105,6 +104,7 @@ define( window.checkoutConfig.bold.fastlane.profileData = profileData; fullScreenLoader.startLoader(); this.setShippingAddress(profileData); + this.isPasswordVisible(false); } return; } diff --git a/view/frontend/web/js/view/shipping-address/list.js b/view/frontend/web/js/view/shipping-address/list.js index d90c539..f7386a5 100644 --- a/view/frontend/web/js/view/shipping-address/list.js +++ b/view/frontend/web/js/view/shipping-address/list.js @@ -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'; @@ -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);