TransWikia.com

Magento 2 : How to modify city field html for shipping address on checkout page

Magento Asked by Ashish Jagnani on February 18, 2021

I need to edit the city field HTML of New shipping address form on checkout in Magento 2.

I am not getting the file from where we can change this or add some classes in these fields. Please share some idea to achieve this.

2 Answers

VendorNameSpaceModuleetcdi.xml

<type name="MagentoCheckoutBlockCheckoutAttributeMerger">
    <plugin name="customAttributeMerger" type="VendorNameSpaceModulePluginAttributeMergerPlugin"/>
</type>

AttributeMergerPlugin.php VendorNameSpaceModulePlugin

<?php
namespace VendorNameSpaceModulePlugin;

class AttributeMergerPlugin
{
    public function afterMerge(MagentoCheckoutBlockCheckoutAttributeMerger $subject, $result)
    {

        if (array_key_exists('city', $result)) {
            $result['city']['additionalClasses'] = 'cusotom_city';
        }

        return $result;
    }
}

Hope this will help you. thanks

Answered by Ranjeet Kumar on February 18, 2021

Here is the path where you can edit city text field for New Shipping Address Form which was rendered form XML file:

app/code/Magento/Checkout/view/frontend/layout/checkout_index_index.xml

Answered by Varma on February 18, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP