Last active
October 29, 2018 15:33
-
-
Save magevision/2bc4f22044d65ba714b46169dd540bc1 to your computer and use it in GitHub Desktop.
ChangeOrderOfAddressFieldsInCheckout
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
<?xml version="1.0"?> | |
<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="magevision_checkout_address_fields_order" type="MageVision\Blog33\Plugin\Checkout\Block\LayoutProcessor" /> | |
</type> | |
</config> |
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
<?php | |
namespace MageVision\Blog33\Plugin\Checkout\Block; | |
class LayoutProcessor { | |
/** | |
* Position the telephone field after address fields | |
* | |
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject | |
* @param array $jsLayout | |
* | |
* @return array | |
*/ | |
public function afterProcess( | |
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject, | |
array $jsLayout | |
) { | |
//Shipping Address | |
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step'] | |
['children']['shippingAddress']['children']['shipping-address-fieldset'] | |
['children']['telephone']['sortOrder'] = 75; | |
//Billing Address on payment method | |
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['payments-list']['children'] | |
)) { | |
$paymentList = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['payments-list']['children']; | |
foreach ($paymentList as $key => $payment) { | |
/* telephone */ | |
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['payments-list']['children'][$key]['children']['form-fields']['children'] | |
['telephone']['sortOrder'] = 75; | |
} | |
} | |
//Billing Address on payment page | |
if (isset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['afterMethods']['children'] | |
)) { | |
/* telephone */ | |
$jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children'] | |
['payment']['children']['afterMethods']['children']['billing-address-form']['children']['form-fields'] | |
['children']['telephone']['sortOrder'] = 75; | |
} | |
return $jsLayout; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment