0

How to remove billing section from checkout page on Magnto2.4.5 enter image description here

1 Answer 1

1

Create di.xml file

    <?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="remove_checkout_billing_address_fields"
type="Vendor\Module\Plugin\Checkout\BillingRemoveAddress" sortOrder="1"/>
        </type>
    </config>

Create BillingRemoveAddress.php

<?php
 
namespace Vendor\Module\Plugin\Checkout;
 
use Magento\Checkout\Block\Checkout\LayoutProcessor;
 
class BillingRemoveAddress
{
    public function afterProcess(
        LayoutProcessor $subject,
        array $result
    )
    {
        $this->result = $result;
        $billingConfiguration = &$this->result['components']['checkout']['children']['steps']['children']['billing-step']
        ['children']['payment']['children']['payments-list']['children'];
 
        if (isset($billingConfiguration)) {
            foreach ($billingConfiguration as $key => &$billingForm) {
                if (!strpos($key, '-form')) {
                    continue;
                }
                if ($billingForm['children']['form-fields']['children']['remove_field']) {
                    unset($billingForm['children']['form-fields']['children']['city']);
                }
 
            }
        }
        return $this->result;
    }
}

and check it.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.