Skip to content

It should be possible to sort the billing address fields in the checkout in a convenient way #6325

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hostep opened this issue Aug 24, 2016 · 10 comments

Comments

@hostep
Copy link
Contributor

hostep commented Aug 24, 2016

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

  1. Take a look at how the billing address fields are composed:
    [
    'country_id' => [
    'sortOrder' => 115,
    ],
    'region' => [
    'visible' => false,
    ],
    'region_id' => [
    'component' => 'Magento_Ui/js/form/element/region',
    'config' => [
    'template' => 'ui/form/field',
    'elementTmpl' => 'ui/form/element/select',
    'customEntry' => 'billingAddress' . $paymentCode . '.region',
    ],
    'validation' => [
    'required-entry' => true,
    ],
    'filterBy' => [
    'target' => '${ $.provider }:${ $.parentScope }.country_id',
    'field' => 'country_id',
    ],
    ],
    'postcode' => [
    'component' => 'Magento_Ui/js/form/element/post-code',
    'validation' => [
    'required-entry' => true,
    ],
    ],
    'company' => [
    'validation' => [
    'min_text_length' => 0,
    ],
    ],
    'fax' => [
    'validation' => [
    'min_text_length' => 0,
    ],
    ],
    'telephone' => [
    'config' => [
    'tooltip' => [
    'description' => __('For delivery questions.'),
    ],
    ],
    ],
    ]
  2. Compare this to the shipping address fields:

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

[
'country_id' => [
'sortOrder' => 115,
],
'region' => [
'visible' => false,
],
'region_id' => [
'component' => 'Magento_Ui/js/form/element/region',
'config' => [
'template' => 'ui/form/field',
'elementTmpl' => 'ui/form/element/select',
'customEntry' => 'billingAddress' . $paymentCode . '.region',
],
'validation' => [
'required-entry' => true,
],
'filterBy' => [
'target' => '${ $.provider }:${ $.parentScope }.country_id',
'field' => 'country_id',
],
],
'postcode' => [
'component' => 'Magento_Ui/js/form/element/post-code',
'validation' => [
'required-entry' => true,
],
],
'company' => [
'validation' => [
'min_text_length' => 0,
],
],
'fax' => [
'validation' => [
'min_text_length' => 0,
],
],
'telephone' => [
'config' => [
'tooltip' => [
'description' => __('For delivery questions.'),
],
],
],
]
this is not possible due to those hardcoded values.

Or am I missing something obvious here?

@piotrekkaminski
Copy link
Contributor

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.

@hostep
Copy link
Contributor Author

hostep commented Sep 16, 2016

@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!

@hostep
Copy link
Contributor Author

hostep commented Sep 19, 2016

@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!

@erfanimani
Copy link
Contributor

erfanimani commented Feb 17, 2017

@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 :/

@gh-darvishani
Copy link

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

@treii28
Copy link

treii28 commented Jun 12, 2018

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!

@Quotacious
Copy link

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.

@qualwebs
Copy link

qualwebs commented Aug 7, 2018

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.

magento-engcom-team pushed a commit that referenced this issue Nov 13, 2020
@braders
Copy link

braders commented Nov 13, 2023

I'd like to propose that this is re-opened. There is a very clear use-case for getBillingAddressComponent to be public, to allow for easy addition of new billing address fields.

@hostep
Copy link
Contributor Author

hostep commented Nov 13, 2023

@braders: could you open a new issue with this request? This is a very old ticket and chances of it being re-opened are not very high I'm afraid.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants