I want to remove required condition on Prename and Surname and only want to use the company name. How can I do this?
1 Answer
1 Override below template to your theme
\vendor\magento\module-customer\view\frontend\templates\widget\name.phtml
Find Below
<input type="text" id="<?php /* @escapeNotVerified */ echo $block->getFieldId('firstname') ?>"
name="<?php /* @escapeNotVerified */ echo $block->getFieldName('firstname') ?>"
value="<?php echo $block->escapeHtml($block->getObject()->getFirstname()) ?>"
title="<?php /* @escapeNotVerified */ echo $block->getStoreLabel('firstname') ?>"
class="input-text <?php /* @escapeNotVerified */ echo $block->getAttributeValidationClass('firstname') ?>" <?php /* @escapeNotVerified */ echo $block->getFieldParams() ?> <?php if ($block->getAttributeValidationClass('firstname') == 'required-entry') echo ' data-validate="{required:true}"' ?>>
Replace with
<input type="text" id="<?php /* @escapeNotVerified */ echo $block->getFieldId('firstname') ?>"
name="<?php /* @escapeNotVerified */ echo $block->getFieldName('firstname') ?>"
value="<?php echo $block->escapeHtml($block->getObject()->getFirstname()) ?>"
title="<?php /* @escapeNotVerified */ echo $block->getStoreLabel('firstname') ?>"
class="input-text" <?php /* @escapeNotVerified */ echo $block->getFieldParams() ?> >
You can follow same things for last name.
After you have to run below query into database
1. UPDATE eav_attribute SET is_required = 0 WHERE attribute_code = 'firstname' and `entity_type_id` = 1;
2. UPDATE eav_attribute SET is_required = 0 WHERE attribute_code = 'last' and `entity_type_id` = 1;