Magento 2 Checkout Glitch: Dynamic Payment Methods Disregard Sort Order

Magento 2 Checkout Glitch: Dynamic Payment Methods Disregard Sort Order

The seamless flow of a Magento 2 checkout is paramount for conversion. However, a recently confirmed GitHub issue (#41127) highlights a critical bug affecting how payment methods are displayed when they become available dynamically during the checkout process. This issue, present in Magento 2.4.x and beyond, can lead to a confusing and inconsistent user experience, potentially impacting customer trust and conversion rates.

The Problem Unveiled: Payment Methods Out of Order

Imagine a scenario where a customer starts their checkout journey in one country, making certain payment methods available. Upon changing their shipping country, new payment options become applicable. The expectation is that these newly available methods will slot into the payment list according to their predefined sort order. Unfortunately, this is not the case.

The issue describes a specific reproduction path:

  • Configure 'Check / Money Order' with a sort order of 10.
  • Configure 'Cash On Delivery' with a sort order of 5, restricted to 'Germany'.
  • As a guest, proceed to checkout with a shipping address in the 'United States'. Only 'Check / Money Order' is visible.
  • Change the shipping country to 'Germany' on the shipping step and proceed to payment.

Expected Result: 'Cash On Delivery' (sort order 5) should appear above 'Check / Money Order' (sort order 10).

Actual Result: 'Cash On Delivery' is consistently appended after 'Check / Money Order', appearing at the very end of the list, completely ignoring its lower sort order.

Diving into the Root Cause: A Frontend Rendering Oversight

The author, BastiaanvdT, meticulously identified the root cause within Magento's frontend JavaScript. The core of the problem lies in app/code/Magento/Checkout/view/frontend/web/js/view/payment/list.js. When a payment method is added to the checkout after the initial page load (e.g., due to a change in shipping address or customer group), the createRenderer() function fails to pass the correct sortOrder to Magento_Ui's layout.addChild() function.

Consequently, layout.addChild(), located in app/code/Magento/Ui/view/base/web/js/core/renderer/layout.js, defaults to a position of -1. This effectively means "append at the end" of the internal elements collection, regardless of the payment method's actual configured sort order. This only impacts dynamically loaded methods; those present from the initial page load render correctly.

Impact and Community Response

While classified as a Severity S3 issue (affecting non-critical functionality without forcing a workaround), this bug can still degrade the user experience. Merchants relying on country-specific or customer group-specific payment methods will find their carefully configured sort orders are not respected, leading to a disorganized payment selection screen.

The Magento community has quickly confirmed the issue. An Adobe Commerce Jira ticket (AC-17968) has been created, and a community contributor, aasim110, has already stepped forward to work on a fix. This swift action underscores the community's commitment to improving Magento's core functionality.

Shopping Mover's Takeaway for Merchants and Developers

For merchants, this highlights the importance of thorough checkout testing, especially with dynamic conditions. If you're experiencing payment method display inconsistencies, this GitHub issue provides a clear explanation. For developers, understanding this root cause is invaluable. While awaiting an official patch, this information can guide temporary workarounds or custom module development to ensure payment methods are always presented in the correct order, maintaining a professional and user-friendly checkout experience.

Start with the tools

Explore migration tools

See options, compare methods, and pick the path that fits your store.

Explore migration tools