Magento2 Checkout – Remove ‘My Billing and Shipping Address Are the Same’

billing-addresscheckoutmagento2onepage-checkoutshipping-address

Can we remove the checkbox and label called "My billing and shipping address are the same" during checkout in Magento2?

I don't want to allow customers to enter billing address there. All I need is to hide the checkbox with the label, can it be done? Please anyone help me.

Best Answer

Overwrite:

vendor/magento/module-checkout/view/frontend/web/template/billing-address.html

in your custom theme:

app/design/frontend/<customTheme>/<customTheme>/Magento_Checkout/web/template/billing-address.html

And remove:

<div class="billing-address-same-as-shipping-block field choice" data-bind="visible: canUseShippingAddress()">
    <input type="checkbox" name="billing-address-same-as-shipping"
           data-bind="checked: isAddressSameAsShipping, click: useShippingAddress, attr: {id: 'billing-address-same-as-shipping-' + getCode($parent)}"/>
    <label data-bind="attr: {for: 'billing-address-same-as-shipping-' + getCode($parent)}"><span
            data-bind="i18n: 'My billing and shipping address are the same'"></span></label>
</div>

So the overwritten file should be like this:

<div class="checkout-billing-address">

<!-- ko template: 'Magento_Checkout/billing-address/details' --><!-- /ko -->
<fieldset class="fieldset" data-bind="visible: !isAddressDetailsVisible()">
    <!-- ko template: 'Magento_Checkout/billing-address/list' --><!-- /ko -->
    <!-- ko template: 'Magento_Checkout/billing-address/form' --><!-- /ko -->
    <div class="actions-toolbar">
        <div class="primary">
            <button class="action action-update" type="button" data-bind="click: updateAddress">
                <span data-bind="i18n: 'Update'"></span>
            </button>
            <button class="action action-cancel" type="button" data-bind="click: cancelAddressEdit">
                <span data-bind="i18n: 'Cancel'"></span>
            </button>
        </div>
    </div>
</fieldset>

UPDATE:

In later versions of Magento, keeping line

<render args="detailsTemplate"/>

prior to

<fieldset class="fieldset" data-bind="visible: !isAddressDetailsVisible()">

is important to retain the functionality.

Related Topic