I want to move the billing address form below the shipping address in the checkout, on the first page/step.
Therefore I created a custom module with the following LayoutProcessorPlugin.php.
But now the billing address field is displayed above the shipping address instead of below. And the default checkbox 'My billing and shipping address are the same' is now unchecked by default.
Also the line to remove the billing address on the billing step is not working. So now this is displayed on both places.
EDIT:
We also tried to use the Tigren method (https://www.tigren.com/billing-under-shipping-address-m2/) or the SR module (https://github.com/sohelrana09/modified-checkout). But these both have the same problem, the prefix is changed into an input field, instead of a select field. So it does not match the options from the backend anymore.
Image of the prefix input field (should be a select with values from backend):
Any idea how to solve this issue?
My LayoutProcessorPlugin.php code;
<?php
namespace Redable\ReorderBillingForm\Model\Checkout;
class LayoutProcessorPlugin
{
/**
* @param \Magento\Checkout\Block\Checkout\LayoutProcessor $subject
* @param array $jsLayout
* @return array
*/
public function afterProcess(
\Magento\Checkout\Block\Checkout\LayoutProcessor $subject,
array $jsLayout
)
{
// get billing address form at billing step
$billingAddressForm = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form'];
// move address form to shipping step
$jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['billing-address-form'] = $billingAddressForm;
// remove form from billing step
unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['afterMethods']['children']['billing-address-form']);
return $jsLayout;
}
}