Created
May 16, 2017 08:31
-
-
Save mrkhoa99/6e67ed8a31efd233165a3aa63cf8168e to your computer and use it in GitHub Desktop.
Magento 2 - change the form fields sort order in checkout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Magento 2 - change the form fields sort order in checkout | |
#app/code/Vendor/Checkout/view/layout/checkout_index_index.xml | |
<page xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 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="component" xsi:type="string">MilkJarCookies_OrderDeliveryDate/js/view/shipping</item> | |
<item name="children" xsi:type="array"> | |
<item name="shipping-address-fieldset" xsi:type="array"> | |
<item name="children" xsi:type="array"> | |
<item name="lastname" xsi:type="array"> | |
<item name="sortOrder" xsi:type="string">20</item> | |
</item> | |
<item name="firstname" xsi:type="array"> | |
<item name="sortOrder" xsi:type="string">21</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</item> | |
</argument> | |
</arguments> | |
</referenceBlock> | |
</body> | |
</page> | |
#app/code/Vendor/Checkout/etc/frontend/di.xml | |
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | |
xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd"> | |
<type name="Magento\Checkout\Block\Checkout\LayoutProcessor"> | |
<plugin name="sort_order_checkout" type="Vendor\Checkout\Plugin\LayoutProcessorPlugin" sortOrder="1"/> | |
</type> | |
</config> | |
#app/code/Vendor/Checkout/Plugin/LayoutProcessorPlugin.php | |
public function aroundProcess($subject, \Closure $proceed, $jsLayout) | |
{ | |
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step'] | |
['children']['shippingAddress']['children']['shipping-address-fieldset']['children']['street']['sortOrder'] = 41; | |
$customJsLayout = $proceed($jsLayout); | |
return $customJsLayout; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Work Around for
https://github.com/magento/magento2/issues/6325
Create private function:
Add after Plugin.