I'm trying to reposition the billing-address-form
below the authentication
form. But I can't figure it out.
What I have done so far
I have found this question, and made a module for it.
<vendor>/<module>/Block/Checkout/LayoutProcessor.php
namespace <vendor>\<module>\Checkout\Block\Checkout; //<-- I think the first Checkout needs to be removed.
use Magento\Checkout\Block\Checkout\LayoutProcessor as LayoutProcessor;
class LayoutProcessorPlugin
{
public function afterProcess(LayoutProcessor $layoutProcessor, callable $proceed): float
{
$jsLayout = $proceed();
// 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;
}
}
<vendor>/<module>/etc/frontend/di.xml
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
<preference for="Magento\Checkout\Block\Checkout\LayoutProcessor" type="<vendor>\<module>\Block\Checkout\LayoutProcessor" />
</config>
But after the compilation I get the following error on the checkout page:
Cannot declare class <vendor>\<module>\Block\Checkout\LayoutProcessorPlugin, because the name is already in use in /app/code/<vendor>/<module>/Block/Checkout/LayoutProcessor.php on line 6