├── .github └── issue_template.md ├── Helper └── Data.php ├── Model └── Config │ └── Source │ ├── AddressAttribute.php │ └── CustomerAttribute.php ├── Plugin ├── Component │ └── AbstractComponentPlugin.php └── Model │ ├── Customer │ └── DataProviderPlugin.php │ └── Metadata │ └── FormPlugin.php ├── README.md ├── composer.json ├── etc ├── acl.xml ├── adminhtml │ ├── di.xml │ └── system.xml └── module.xml ├── i18n └── en_US.csv └── registration.php /.github/issue_template.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | #### Magento version #: 7 | 8 | #### Edition (EE, CE, OS, etc): 9 | 10 | #### Expected behavior: 11 | 12 | #### Actual behavior: 13 | 14 | #### Steps to reproduce: 15 | 16 | #### Preconditions 17 | 18 | 19 | 20 | 21 | 37 | -------------------------------------------------------------------------------- /Helper/Data.php: -------------------------------------------------------------------------------- 1 | scopeConfig->isSetFlag(self::XML_PATH_ACTIVE, ScopeInterface::SCOPE_STORE); 31 | } 32 | 33 | /** 34 | * Check page type 35 | * @return bool 36 | */ 37 | public function isCustomerEditAdminPage() 38 | { 39 | return $this->_request->getFullActionName() === 'customer_index_edit'; 40 | } 41 | 42 | /** 43 | * Check page type 44 | * @return bool 45 | */ 46 | public function isSalesOrderFormAdminPage() 47 | { 48 | return $this->_request->getFullActionName() === 'sales_order_create_index' 49 | || $this->_request->getFullActionName() === 'sales_order_create_loadBlock' 50 | || $this->_request->getFullActionName() === 'sales_order_edit_index' 51 | || $this->_request->getFullActionName() === 'sales_order_edit_loadBlock'; 52 | } 53 | 54 | /** 55 | * Get list of customer attribute to disabled 56 | * @return string|null 57 | */ 58 | public function getCustomerAttribute() 59 | { 60 | return $this->scopeConfig->getValue(self::XML_CUSTOMER_ATTRIBUTE, ScopeInterface::SCOPE_STORE); 61 | } 62 | 63 | /** 64 | * Get list of customer attribute to disabled 65 | * @return string|null 66 | */ 67 | public function getCustomerAddressAttribute() 68 | { 69 | return $this->scopeConfig->getValue( 70 | self::XML_CUSTOMER_ADDRESS_ATTRIBUTE, 71 | ScopeInterface::SCOPE_STORE 72 | ); 73 | } 74 | 75 | /** 76 | * Get Array of customer attribute to disabled 77 | * @return array 78 | */ 79 | public function getCustomerAttributeArray() 80 | { 81 | $list = $this->getCustomerAttribute(); 82 | 83 | return empty($list) ? [] : explode(',', $list); 84 | } 85 | 86 | /** 87 | * Get Array of customer attribute to disabled 88 | * @return array 89 | */ 90 | public function getCustomerAddressAttributeArray() 91 | { 92 | $list = $this->getCustomerAddressAttribute(); 93 | 94 | return empty($list) ? [] : explode(',', $list); 95 | } 96 | 97 | /** 98 | * check if array path exists 99 | * @param $array 100 | * @param $path 101 | * @param string $separator 102 | * @return bool 103 | */ 104 | public function arrayPathExists($array, $path, $separator = '/') 105 | { 106 | $paths = explode($separator, $path); 107 | 108 | foreach ($paths as $sub) { 109 | if (!is_array($array) || !array_key_exists($sub, $array)) { 110 | return false; 111 | } 112 | 113 | $array = $array[$sub]; 114 | } 115 | 116 | return true; 117 | } 118 | } 119 | -------------------------------------------------------------------------------- /Model/Config/Source/AddressAttribute.php: -------------------------------------------------------------------------------- 1 | _customerFormFactory = $customerFormFactory; 35 | } 36 | 37 | /** 38 | * @return array 39 | */ 40 | public function toOptionArray() 41 | { 42 | //todo: rewrite using eav config see Magento/Customer/Model/Customer/DataProvider.php 43 | //$this->eavConfig->getEntityType('customer')->getAttributeCollection() 44 | 45 | $customerForm = $this->_customerFormFactory->create( 46 | AddressMetadataInterface::ENTITY_TYPE_ADDRESS, 47 | 'adminhtml_customer_address' 48 | ); 49 | 50 | $attributes = $customerForm->getAttributes(); 51 | 52 | $fields = []; 53 | 54 | $ignoreList = ['created_at', 'created_in', 'disable_auto_group_change', 'region', 'region_id', 'postcode']; 55 | 56 | foreach ($attributes as $attribute) { 57 | if (!$attribute->isRequired() && !in_array($attribute->getAttributeCode(), $ignoreList)) { 58 | $fields[] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getStoreLabel()]; 59 | } 60 | } 61 | 62 | return $fields; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Model/Config/Source/CustomerAttribute.php: -------------------------------------------------------------------------------- 1 | _customerFormFactory = $customerFormFactory; 35 | } 36 | 37 | /** 38 | * @return array 39 | */ 40 | public function toOptionArray() 41 | { 42 | //todo: rewrite using eav config see Magento/Customer/Model/Customer/DataProvider.php 43 | //$this->eavConfig->getEntityType('customer')->getAttributeCollection() 44 | 45 | $customerForm = $this->_customerFormFactory->create( 46 | CustomerMetadataInterface::ENTITY_TYPE_CUSTOMER, 47 | 'adminhtml_customer' 48 | ); 49 | 50 | $attributes = $customerForm->getAttributes(); 51 | 52 | $fields = []; 53 | 54 | $ignoreList = ['created_at', 'created_in', 'disable_auto_group_change']; 55 | 56 | foreach ($attributes as $attribute) { 57 | if (!$attribute->isRequired() && !in_array($attribute->getAttributeCode(), $ignoreList)) { 58 | $fields[] = ['value' => $attribute->getAttributeCode(), 'label' => $attribute->getStoreLabel()]; 59 | } 60 | } 61 | 62 | return $fields; 63 | } 64 | } 65 | -------------------------------------------------------------------------------- /Plugin/Component/AbstractComponentPlugin.php: -------------------------------------------------------------------------------- 1 | _dataHelper = $dataHelper; 30 | } 31 | 32 | /** 33 | * @param AbstractComponent $subject 34 | * @param $result 35 | * @return array 36 | */ 37 | public function afterGetChildComponents(AbstractComponent $subject, $result) 38 | { 39 | if ($this->_dataHelper->isCustomerEditAdminPage() && $this->_dataHelper->isEnabled()) { 40 | if ($subject->getName() == 'customer') { 41 | $this->hideFields($result, $this->_dataHelper->getCustomerAttributeArray()); 42 | } elseif ($subject->getName() == 'address') { 43 | $this->hideFields($result, $this->_dataHelper->getCustomerAddressAttributeArray()); 44 | } 45 | } 46 | 47 | return $result; 48 | } 49 | 50 | /** 51 | * @param $result 52 | * @param $fields 53 | */ 54 | private function hideFields(&$result, $fields) 55 | { 56 | if (is_array($result)) { 57 | foreach ($fields as $field) { 58 | if (array_key_exists($field, $result)) { 59 | $temp = $result[$field]->getConfig(); 60 | $temp['visible'] = false; 61 | $result[$field]->setConfig($temp); 62 | } 63 | } 64 | } 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Plugin/Model/Customer/DataProviderPlugin.php: -------------------------------------------------------------------------------- 1 | _dataHelper = $dataHelper; 31 | $this->timezone = $timezone; 32 | } 33 | 34 | /** 35 | * @param DataProvider $subject 36 | * @param $result 37 | * @return mixed 38 | */ 39 | public function afterGetData(DataProvider $subject, $result) 40 | { 41 | //check if dob is hidden and need to change the date format 42 | if ($this->_dataHelper->isCustomerEditAdminPage() && $this->_dataHelper->isEnabled()) { 43 | if (is_array($result) && in_array('dob', $this->_dataHelper->getCustomerAttributeArray())) { 44 | if ($this->_dataHelper->arrayPathExists($result, '1/customer/dob')) { 45 | $result[1]['customer']['dob'] = $this->timezone 46 | ->date($result[1]['customer']['dob']) 47 | ->format('m/d/Y'); 48 | } 49 | } 50 | } 51 | 52 | return $result; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /Plugin/Model/Metadata/FormPlugin.php: -------------------------------------------------------------------------------- 1 | _dataHelper = $dataHelper; 29 | } 30 | 31 | /** 32 | * @param Form $subject 33 | * @param $result 34 | * @return array 35 | */ 36 | public function afterGetAttributes(Form $subject, $result) 37 | { 38 | if ($this->_dataHelper->isSalesOrderFormAdminPage() && $this->_dataHelper->isEnabled() && is_array($result)) { 39 | foreach ($this->_dataHelper->getCustomerAddressAttributeArray() as $field) { 40 | if (array_key_exists($field, $result)) { 41 | unset($result[$field]); 42 | } 43 | } 44 | } 45 | 46 | return $result; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | # Customer and Address Form Fields Manager for Magento2 4 | 5 | [![Total Downloads](https://poser.pugx.org/magepal/magento2-form-field-manager/downloads)](https://www.magepal.com/magento2/extensions/admin-form-fields-manager-for-magento-2.html) 6 | [![Latest Stable Version](https://poser.pugx.org/magepal/magento2-form-field-manager/v/stable)](https://www.magepal.com/magento2/extensions/admin-form-fields-manager-for-magento-2.html) 7 | 8 | 9 | Magento Extensions 10 | 11 | Quickly and easily remove unwanted form fields from admin order creation and customer account, added by default magento or other third party extensions 12 | 13 | 14 | ![Magento2 Configuration](https://user-images.githubusercontent.com/1415141/31972382-717b22a6-b8ee-11e7-8549-934d87ed01b1.png) 15 | 16 | ### After (Admin order creation) 17 | ![Magento Admin order creation](https://user-images.githubusercontent.com/1415141/31972782-5de22300-b8f0-11e7-8330-8e056d072e4b.png) 18 | 19 | ### Features 20 | - Remove unneeded form fields from: 21 | - Admin order creation 22 | - Customer admin 23 | 24 | - No code or template modification 25 | 26 | - Switch on/off form fields via Magento backend. 27 | 28 | #### Customer Attributes 29 | - Name Prefix 30 | - Middle Name/Initial 31 | - Name Suffix 32 | - Date of Birth 33 | - Tax/VAT Number 34 | - Gender 35 | 36 | 37 | #### Address Attributes 38 | - Name Prefix 39 | - Middle Name/Initial 40 | - Name Suffix 41 | - Company 42 | - Fax 43 | - VAT Number 44 | 45 | ### Installation 46 | #### Step 1 - Installation Customer Account Links Manager 47 | 48 | ##### Using Composer (recommended) 49 | ``` 50 | composer require magepal/magento2-form-field-manager 51 | ``` 52 | 53 | ##### Manually 54 | * Download the extension 55 | * Unzip the file 56 | * Create a folder {Magento 2 root}/app/code/MagePal/FormFieldManager 57 | * Copy the content from the unzip folder 58 | 59 | 60 | #### Step 2 - Enable Customer Account Links Manager (from {Magento root} folder) 61 | * php -f bin/magento module:enable --clear-static-content MagePal_FormFieldManager 62 | * php -f bin/magento setup:upgrade 63 | 64 | #### Step 3 - Configure Customer Account Links Manager 65 | 66 | Log into your Magento 2 Admin, then goto Stores -> Configuration -> MagePal -> Form Field Manager 67 | 68 | Contribution 69 | --- 70 | Want to contribute to this extension? The quickest way is to open a [pull request on GitHub](https://help.github.com/articles/using-pull-requests). 71 | 72 | Support 73 | --- 74 | If you encounter any problems or bugs, please open an issue on [GitHub](https://github.com/magepal/magento2-formfieldmanager/issues). 75 | 76 | Need help setting up or want to customize this extension to meet your business needs? Please email support@magepal.com and if we like your idea we will add this feature for free or at a discounted rate. 77 | 78 | Magento 2 Extensions 79 | --- 80 | - [Custom SMTP](https://www.magepal.com/magento2/extensions/custom-smtp.html) 81 | - [Catalog Hover Image for Magento](https://www.magepal.com/magento2/extensions/catalog-hover-image-for-magento.html) 82 | - [Enhanced Success Page for Magento 2](https://www.magepal.com/magento2/extensions/enhanced-success-page.html) 83 | - [Enhanced Transactional Emails for Magento 2](https://www.magepal.com/magento2/extensions/enhanced-transactional-emails.html) 84 | - [Google Tag Manager](https://www.magepal.com/magento2/extensions/google-tag-manager.html) 85 | - [Enhanced E-commerce](https://www.magepal.com/magento2/extensions/enhanced-ecommerce-for-google-tag-manager.html) 86 | - [Reindex](https://www.magepal.com/magento2/extensions/reindex.html) 87 | - [Custom Shipping Method](https://www.magepal.com/magento2/extensions/custom-shipping-rates-for-magento-2.html) 88 | - [Preview Order Confirmation](https://www.magepal.com/magento2/extensions/preview-order-confirmation-page-for-magento-2.html) 89 | - [Guest to Customer](https://www.magepal.com/magento2/extensions/guest-to-customer.html) 90 | - [Admin Form Fields Manager](https://www.magepal.com/magento2/extensions/admin-form-fields-manager-for-magento-2.html) 91 | - [Customer Dashboard Links Manager](https://www.magepal.com/magento2/extensions/customer-dashboard-links-manager-for-magento-2.html) 92 | - [Lazy Loader](https://www.magepal.com/magento2/extensions/lazy-load.html) 93 | - [Order Confirmation Page Miscellaneous Scripts](https://www.magepal.com/magento2/extensions/order-confirmation-miscellaneous-scripts-for-magento-2.html) 94 | - [HTML Minifier for Magento2](https://www.magepal.com/magento2/extensions/html-minifier.html) 95 | 96 | © MagePal LLC. | [www.magepal.com](https://www.magepal.com) 97 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "magepal/magento2-form-field-manager", 3 | "description": "Customer and Address Form Fields Manager for Magento2", 4 | "keywords": [ 5 | "magento 2", 6 | "admin customer", 7 | "admin customer address", 8 | "magento remove address fields", 9 | "how to edit magento2 address fields" 10 | ], 11 | "license": [ 12 | "proprietary" 13 | ], 14 | "homepage": "https://www.magepal.com/", 15 | "support": { 16 | "email": "support@magepal.com", 17 | "issues": "https://github.com/magepal/magento2-form-field-manager/issues/" 18 | }, 19 | "authors": [ 20 | { 21 | "name": "Renon Stewart", 22 | "email": "renon@magepal.com", 23 | "homepage": "https://www.magepal.com/", 24 | "role": "Leader" 25 | } 26 | ], 27 | "require": { 28 | "php": "~7.2.0|~7.3.0|~7.4.0|~8.1.0|~8.2.0|~8.3.0|~8.4.0", 29 | "magento/module-backend": "100.0.*|100.1.*|100.2.*|101.0.*|102.0.*", 30 | "magento/framework": "100.0.*|100.1.*|101.0.*|102.0.*|103.0.*", 31 | "magepal/magento2-core": ">=1.1.10" 32 | }, 33 | "type": "magento2-module", 34 | "version": "1.1.4", 35 | "autoload": { 36 | "files": [ 37 | "registration.php" 38 | ], 39 | "psr-4": { 40 | "MagePal\\FormFieldManager\\": "" 41 | } 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /etc/acl.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /etc/adminhtml/di.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 13 | 14 | 15 | 17 | 18 | 19 | 21 | 22 | 23 | -------------------------------------------------------------------------------- /etc/adminhtml/system.xml: -------------------------------------------------------------------------------- 1 | 2 | 9 | 10 | 11 | 12 | 13 | 14 |
15 | 16 | magepal 17 | MagePal_FormFieldManager::magepal_formfieldmanager 18 | 19 | 20 | 21 | Copyright © 2024 www.magepal.com / support@magepal.com
23 | Discover other must have extensions at www.magepal.com. Thanks for choosing MagePal Extensions.

24 |
25 | ]]> 26 |
27 | 28 | 29 | MagePal\Core\Block\Adminhtml\System\Config\Composer\Version 30 | 31 |
32 | 33 | 34 | 35 | 36 | Magento\Config\Model\Config\Source\Yesno 37 | 38 | 39 | 40 | 41 | MagePal\FormFieldManager\Model\Config\Source\CustomerAttribute 42 | 43 | 44 | 45 | MagePal\FormFieldManager\Model\Config\Source\AddressAttribute 46 | 47 | 48 |
49 |
50 |
51 | -------------------------------------------------------------------------------- /etc/module.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /i18n/en_US.csv: -------------------------------------------------------------------------------- 1 | "Module Version","Module Version" 2 | "Composer Version","Composer Version" 3 | "Enable","Enable" 4 | "Customer Attribute","Customer Attribute" 5 | "Customer Address Attribute","Customer Address Attribute" 6 | -------------------------------------------------------------------------------- /registration.php: -------------------------------------------------------------------------------- 1 |