How To

Magento 2: How to Move Billing Address before Payment Methods in Checkout Page

Hello Magento Friends,

Today I will provide a solution on How to Move Billing Address before Payment Methods on Magento 2 Checkout Page.

In default Magento 2, the billing address is displayed after the payment methods at the checkout page. Check the default checkout page in Magento 2.

If you have a custom requirement to display the billing address before the payment methods, you can use the below method.

Steps to Move Billing Address before Payment Methods in Checkout Page in Magento 2:

Step 1: Create a di.xml file in the below path.

{{magento_root}}/app/code/Vendor/Extension/etc/di.xml

Now add the below code snippet

<?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="Checkout_ICustom"
                type="Vendor\Extension\Plugin\Block\Checkout\LayoutProcessor"/>
    </type>
     
</config>

Step 2: Create the plugin file LayoutProcessor.php as the following path.

{{magento_root}}/app/code/Vendor/Extension/Plugin/Block/Checkout/LayoutProcessor.php

Then include the below-mentioned code

<?php 

namespace Vendor\Extension\Plugin\Block\Checkout;

use Magento\Checkout\Block\Checkout\LayoutProcessor as Checkout;

class LayoutProcessor
{
    public function afterProcess(
        Checkout $subject,
        array $jsLayout
    ): array {
        $paymentLayout = $jsLayout['components']['checkout']['children']['steps']
        ['children']['billing-step']['children']['payment']['children'];

        if (isset($paymentLayout['afterMethods']['children']['billing-address-form'])) {
            $jsLayout['components']['checkout']['children']['steps']
            ['children']['billing-step']['children']['payment']['children']
            ['beforeMethods']['children']['billing-address-form']
                = $paymentLayout['afterMethods']['children']['billing-address-form'];

            unset($jsLayout['components']['checkout']['children']['steps']
            ['children']['billing-step']['children']['payment']
            ['children']['afterMethods']['children']['billing-address-form']);
        }
        return $jsLayout;
    }
}

After implementing the above steps, you can go to the checkout page and see that the billing address is displayed before the payment methods.

Conclusion:

Hence, this way, you can Move the Billing Address before Payment Methods on Magento 2 Checkout Page. Using Magento 2 Custom Checkout Fields Extension, you can customize the checkout page by adding custom fields.

Share the tutorial with your friends and stay in touch with us for more solutions.

Happy Coding!

Click to rate this post!
[Total: 3 Average: 5]
Dhiren Vasoya

Dhiren Vasoya is a Director and Co-founder at MageComp, Passionate ?️ Certified Magento Developer?‍?. He has more than 9 years of experience in Magento Development and completed 850+ projects to solve the most important E-commerce challenges. He is fond❤️ of coding and if he is not busy developing then you can find him at the cricket ground, hitting boundaries.?

Recent Posts

Improving Error Handling and Transition Management in Remix with useRouteError and useViewTransitionState

In modern web development, seamless navigation and state management are crucial for delivering a smooth…

6 days ago

Magento Open Source 2.4.8-Beta Release Notes

Magento Open Source 2.4.8 beta version released on October  8, 2024. The latest release of…

1 week ago

How to Create Catalog Price Rule in Magento 2 Programmatically?

Hello Magento Friends, Creating catalog price rules programmatically in Magento 2 can be a valuable…

1 week ago

Top 10 Tips to Hire Shopify Developers

As the world of eCommerce continues to thrive, Shopify has become one of the most…

2 weeks ago

Managing Browser Events and Navigation in Shopify Remix: useBeforeUnload, useHref, and useLocation Hooks

Shopify Remix is an innovative framework that provides a streamlined experience for building fast, dynamic,…

2 weeks ago

Ultimate Guide to Hiring a Top Shopify Development Agency

Building a successful eCommerce store requires expertise, and for many businesses, Shopify has become the…

2 weeks ago