Fixed payment method sort order not respected when added to checkout after initial render - #41128
Fixed payment method sort order not respected when added to checkout after initial render#41128BastiaanvdT wants to merge 1 commit into
Conversation
|
Hi @BastiaanvdT. Thank you for your contribution!
Allowed build names are:
You can find more information about the builds here For more details, review the Code Contributions documentation. |
|
@magento run all tests |
|
@magento run Functional Tests CE, Functional Tests B2B, Functional Tests EE |
|
@engcom-Bravo Kindly review this PR as all tests are completed and functional tests fails are not related to this PR |
Description (*)
Magento_Checkout/js/view/payment/list.js#createRendererinserts newly added payment method renderers vialayout()without specifying asortOrderon the node.Magento_Ui'slayout.addChild()useschild.sortOrderas the insertion position in the parent's internal_elemscollection; without it, the position defaults to-1(append at the end), regardless of the method's actual order in thepaymentMethods()list.This means a payment method whose availability depends on dynamic conditions (e.g. restricted to specific countries, so it's added to
paymentMethods()only after a shipping address change) always renders last, even if its configured sort order says otherwise.The fix passes the method's index in the current
paymentMethods()list assortOrderon the renderer node, soMagento_Ui's existing ordered-insertion mechanism (the same one used for all statically XML-declared children) places it correctly — no custom sorting/reordering logic needed.Changed files:
app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.jsRelated Pull Requests
None.
Fixed Issues (if relevant)
Manual testing scenarios (*)
Contribution checklist (*)