Magento2: It should be possible to sort the billing address fields in the checkout in a convenient way

Created on 24 Aug 2016  路  8Comments  路  Source: magento/magento2

Preconditions

  1. Magento CE 2.1.0
  2. A whole afternoon of debugging joy (oh no, I already did this for you, don't worry)

    Steps to reproduce

  3. Take a look at how the _billing_ address fields are composed: https://github.com/magento/magento2/blob/c5d618d5439362f50ba0f21d3fadf418cc765190/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php#L201-L246

  4. Compare this to the _shipping_ address fields: https://github.com/magento/magento2/blob/c5d618d5439362f50ba0f21d3fadf418cc765190/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php#L165

    Expected result

I expected to be able to change the sort order of the _billing_ address fields in the checkout using xml or some other "convenient" way, but found this is almost impossible without manually altering the sort_order field in the customer_eav_attribute table.

Actual result

Not able to sort the _billing_ address fields in a convenient and easy way.

Discussion

To be able to sort the _shipping_ address fields in the checkout, we can create a file checkout_index_index.xml with something like this:

<?xml version="1.0"?>
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" layout="checkout" xsi:noNamespaceSchemaLocation="urn:magento:framework:View/Layout/etc/page_configuration.xsd">
    <body>
        <referenceBlock name="checkout.root">
            <arguments>
                <argument name="jsLayout" xsi:type="array">
                    <item name="components" xsi:type="array">
                        <item name="checkout" xsi:type="array">
                            <item name="children" xsi:type="array">
                                <item name="steps" xsi:type="array">
                                    <item name="children" xsi:type="array">
                                        <item name="shipping-step" xsi:type="array">
                                            <item name="children" xsi:type="array">
                                                <item name="shippingAddress" xsi:type="array">
                                                    <item name="children" xsi:type="array">
                                                        <item name="shipping-address-fieldset" xsi:type="array">
                                                            <item name="children" xsi:type="array">
                                                                <item name="region_id" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">87</item>
                                                                </item>
                                                                <item name="postcode" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">80</item>
                                                                </item>
                                                                <item name="company" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">45</item>
                                                                </item>
                                                                <item name="vat_id" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">46</item>
                                                                </item>
                                                                <item name="country_id" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">85</item>
                                                                </item>
                                                                <item name="telephone" xsi:type="array">
                                                                    <item name="sortOrder" xsi:type="string">90</item>
                                                                </item>
                                                            </item>
                                                        </item>
                                                    </item>
                                                </item>
                                            </item>
                                        </item>
                                    </item>
                                </item>
                            </item>
                        </item>
                    </item>
                </argument>
            </arguments>
        </referenceBlock>
    </body>
</page>

I was hoping there was a similar way for the _billing_ address fields, but came to the conclusion after viewing https://github.com/magento/magento2/blob/c5d618d5439362f50ba0f21d3fadf418cc765190/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php#L201-L246 this is not possible due to those hardcoded values.

Or am I missing something obvious here?

Customer bug report improvement

Most helpful comment

@piotrekkaminski: seriously? This is a flaw in Magento 2.
I don't consider this a feature request but an actual bug, because we are unable to order the billing address fields in a convenient way like we can order the shipping address fields. Except for hacking the core or the database.
Please reconsider this. Thanks!

All 8 comments

Thank you for your submission.

We recently made some changes to the way we process GitHub submissions to more quickly identify and respond to core code issues.

Feature Requests and Improvements should now be submitted to the new Magento 2 Feature Requests and Improvements forum (see details here).

We are closing this GitHub ticket and have moved your request to the new forum.

@piotrekkaminski: seriously? This is a flaw in Magento 2.
I don't consider this a feature request but an actual bug, because we are unable to order the billing address fields in a convenient way like we can order the shipping address fields. Except for hacking the core or the database.
Please reconsider this. Thanks!

@piotrekkaminski: I saw you mentioning in another issue that your piotrekkaminski-lets-move-everything-to-the-forums-bot does it job automatically based on the tags which are assigned to the issue, and sometimes mistakenly moves issues over to the forum due to a bug in the bot.
Can you review this particular issue and please let me know what the reason is that this issue is moved to the forums? Or if the closing of this issue is actually also caused by that same bug, and then you can reopen this issue.
It would also be great if the author of the issue can reopen it if he/she doesn't agree with the bot.

Thank you!

@hostep, I referenced the issue here: https://community.magento.com/t5/forums/editpage/board-id/feature-requests/message-id/2710

Imo it smells like a bug - not for end-users, but definitely for developers wishing to use the layout XML API. Also, you can't even change it with plugins, since getBillingAddressComponent is a private method :/

we are in 2018 ...and no solutions found?
Should we wait to solve this problem?

One thing I just noted is that there seems to be a hard-code override for the country_id sort order in (at least my v2.2.2) magento2 CE in the module-checkout package. I wasted 3 hours trying to figure out why changing the values in customer_eav_attribute sortOrder for the country_id didn't seem to be changing anything only to find it was hard-code over-ridden in the original sourcecode!

This really needs to be corrected. It is frustrating as a new customer to try to select your State/Province only to find the list is for the US or other country, and then have to illogically go further down to change the Country and then go back up to select their State/Province.

I've solved at-least or even more than 10 critical bugs myself after release of magento 2, having shipping and billing address on checkout is of core importance when it comes to an ecommerce site, I'm very sure the world's most robust and secure ecommerce CMS Magento 2 must have a solution for this but where is it ? please help to sort this issue or at-least accept that no solution till date has been given so we can develop one by ourselves.

Was this page helpful?
0 / 5 - 0 ratings