magento2: Billing Address Form does not preload billing address after page refresh when Display Billing Address On is set Payment Page
Preconditions (*)
- Magento 2.4.2
- Vanilla, clean install with sample-data
Steps to reproduce (*)
- Go to admin -> store -> config -> sales -> checkout and set
Display Billing Address OntoPayment Page - Go to frontend -> add any product to the cart
- Go to checkout and fill email, shipping address and choose shipping method
- Go to payment step, uncheck
My billing and shipping address are the same - Fill new address in the billing address form and click update
- Now, refresh the page and click edit on the billing address
- Form is empty, without values.
Video: https://www.dropbox.com/s/qqplkwkaqbo0phz/billingAddress-issue.mov?dl=0
Expected result (*)
- After filling in the billing address form a different billing address than shipping address and refreshing the page, it should preload the data of the billing address in the form.
- Data is there, in the localStorage
PS. all the other components are preloaded: email, shipping address, shipping method, payment method.
Actual result (*)
- Form of billing address after refresh page is not preloading the previously saved billing address, which is different than the shipping address.
Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.
- Severity: S0 - Affects critical data or functionality and leaves users without workaround.
- Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
- Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
- Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
- Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
About this issue
- Original URL
- State: open
- Created 3 years ago
- Comments: 15 (4 by maintainers)
I have investigated the issue on M2.4.4 and found the following behaviour. In my example I am using the payment method checkmo. The affected file: https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/Checkout/view/frontend/web/js/view/payment/default.js
Display Billing Address OntoPayment Method: ThebillingAddressCodeon line 68 isbillingAddresscheckmo. IncheckoutProviderthere is an empty address object for each payment method calledbillingAddress + payment code, so in our case it will bebillingAddresscheckmo. On line 72defaultAddressDatais not undefined because ourbillingAddressCodeexists incheckoutProviderand sobillingAddressDatawill be the previously added billing address. Everything works fine here.Display Billing Address OntoPayment Page:billingAddressCodeon line 68 will bebillingAddresscheckmo. IncheckoutProviderthere is a single empty address object calledbillingAddressshared. On line 72defaultAddressDatais undefined because ourbillingAddressCodedoesn’t exist incheckoutProvider, so we run in the return statement and previously added billing address is not inserted.The problem is, that
billingAddressCodewill staybillingAddress + payment codebut the object incheckoutProviderchanges name tobillingAddress + shared.I don’t know if this is the best solution, but if we change line 68 to
billingAddressCode = 'billingAddress' + (window.checkoutConfig.displayBillingOnPaymentMethod ? this.getCode() : 'shared');everything will work as expected.Hi @abude , Issue is reproducible on Magento 2.4.2 instance & Magento 2.4 Develop. Hence adding the label ‘Issue confirmed’. Kindly find the attached screenshots for reference.