0

I have to Hide Some of the Fields from shipping and Billing Adress how I can achieve this need guidance thank you

asked Jun 28, 2020 at 17:12

3 Answers 3

4

Step-1

please open the file Magento\Sales\Block\Adminhtml\Order\Create\Form\Address.php and check there is _prepareForm method please add below 2 lines and override the block

protected function _prepareForm()
 {
 '''''''''''''''''''''
 $attributes = $addressForm->getAttributes();
 unset($attributes['prefix']);
 unset($attributes['suffix']);
 .........................
}

I hope this is helpful to you!!

answered Jun 30, 2020 at 6:41
1
  • But unable to override this file, can you please tell at which layout file this block file class mentioned? Commented Aug 28, 2020 at 19:56
0

I assume you are after remove a field?

Add a plugin for the Model Magento\Checkout\Block\Checkout\LayoutProcessor

<?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="layout_checkout_process" type="Mbs\ModuleName\Plugin\CheckoutLayoutProcess" />
 </type>
</config>

the plugin like below:

<?php
use Magento\Checkout\Block\Checkout\LayoutProcessor;
use Magento\Framework\App\Config\ScopeConfigInterface;
class CheckoutLayoutProcess
{
 /**
 * @var ScopeConfigInterface
 */
 private $scopeConfig;
 public function __construct(
 ScopeConfigInterface $scopeConfig
 ) {
 $this->scopeConfig = $scopeConfig;
 }
 public function afterProcess(LayoutProcessor $subject, $jsLayout)
 {
 $fieldNameToRemove = 'firstname';
 unset($jsLayout['components']['checkout']['children']['steps']['children']['shipping-step']['children']['shippingAddress']['children']['shipping-address-fieldset']['children'][$fieldNameToRemove]);
 if ($this->isBillingOnPaymentPage()) {
 unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']
 ['children']['afterMethods']['children']['billing-address-form']['children']['form-fields']['children'][$fieldNameToRemove]);
 } else {
 $configuration = $jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']['payment']['children']['payments-list']['children'];
 foreach ($configuration as $paymentGroup => $groupConfig) {
 if (isset($groupConfig['component']) and $groupConfig['component'] === 'Magento_Checkout/js/view/billing-address') {
 unset($jsLayout['components']['checkout']['children']['steps']['children']['billing-step']['children']
 ['payment']['children']['payments-list']['children'][$paymentGroup]['children']['form-fields']['children'][$fieldNameToRemove]);
 }
 }
 }
 return $jsLayout;
 }
 private function isBillingOnPaymentPage()
 {
 return $this->scopeConfig->getValue('checkout/options/display_billing_address_on');
 }
}
answered Jun 29, 2020 at 19:56
0

You need to remove a field from customer_form_attribute Table

SELECT * FROM eav_attribute WHERE attribute_id = 537

SELECT * FROM customer_form_attribute WHERE attribute_id = 537

Image Reference -> https://i.sstatic.net/6F8R2.png

You need to remove the form_code base on your requirement after cache clean and flush.

Note: this solution work for me.

answered Jul 30, 2021 at 11:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.