Make "is_required" and "is_visible" properties of telephone, company and fax attributes of addresses configurable#8519
Conversation
…phone" not being a required field
…ing a required field
…/magento2 into telephone-not-required
| <div class="control"> | ||
| <input type="text" name="company" id="company" value="<?php echo $block->escapeHtmlAttr($block->getCompany()) ?>" title="<?php echo $block->escapeHtmlAttr(__('Company')) ?>" class="input-text <?php echo $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('company')) ?>"> | ||
| </div> | ||
| </div> No newline at end of file |
There was a problem hiding this comment.
Will be nice to improve code formatting in templates 😉 Copy-paste code bellow.
<div class="field company <?php echo $block->isRequired() ? 'required' : '' ?>">
<label for="company" class="label">
<span>
<?php echo $block->escapeHtml(__('Company')) ?>
</span>
</label>
<div class="control">
<?php
$_validationClass = $block->escapeHtmlAttr(
$this->helper('Magento\Customer\Helper\Address')
->getAttributeValidationClass('company')
);
?>
<input type="text"
name="company"
id="company"
value="<?php echo $block->escapeHtmlAttr($block->getCompany()) ?>"
title="<?php echo $block->escapeHtmlAttr(__('Company')) ?>"
class="input-text <?php echo $_validationClass ?? '' ?>"
>
</div>
</div>PS. Remember about new line at the end of file.
| <div class="control"> | ||
| <input type="text" name="fax" id="fax" value="<?php echo $block->escapeHtmlAttr($block->getFax()) ?>" title="<?php echo $block->escapeHtmlAttr(__('Fax')) ?>" class="input-text <?php echo $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('fax')) ?>"> | ||
| </div> | ||
| </div> No newline at end of file |
There was a problem hiding this comment.
<div class="field fax <?php echo $block->isRequired() ? 'required' : '' ?>">
<label for="fax" class="label">
<span>
<?php echo $block->escapeHtml(__('Fax')) ?>
</span>
</label>
<div class="control">
<?php
$_validationClass = $block->escapeHtmlAttr(
$this->helper('Magento\Customer\Helper\Address')
->getAttributeValidationClass('fax')
);
?>
<input type="text"
name="fax"
id="fax"
value="<?php echo $block->escapeHtmlAttr($block->getFax()) ?>"
title="<?php echo $block->escapeHtmlAttr(__('Fax')) ?>"
class="input-text <?php echo $_validationClass ?? '' ?>"
>
</div>
</div>| <div class="control"> | ||
| <input type="text" name="telephone" id="telephone" value="<?php echo $block->escapeHtmlAttr($block->getTelephone()) ?>" title="<?php echo $block->escapeHtmlAttr(__('Phone Number')) ?>" class="input-text <?php echo $block->escapeHtmlAttr($this->helper('Magento\Customer\Helper\Address')->getAttributeValidationClass('telephone')) ?>"> | ||
| </div> | ||
| </div> |
There was a problem hiding this comment.
<div class="field telephone <?php echo $block->isRequired() ? 'required' : '' ?>">
<label for="telephone" class="label">
<span>
<?php echo $block->escapeHtml(__('Phone Number')) ?>
</span>
</label>
<div class="control">
<?php
$_validationClass = $block->escapeHtmlAttr(
$this->helper('Magento\Customer\Helper\Address')
->getAttributeValidationClass('fax')
);
?>
<input type="text"
name="telephone"
id="telephone"
value="<?php echo $block->escapeHtmlAttr($block->getTelephone()) ?>"
title="<?php echo $block->escapeHtmlAttr(__('Phone Number')) ?>"
class="input-text <?php echo $_validationClass ?? '' ?>"
>
</div>
</div>|
Nice work @avstudnitz! Just something I have to think about, take a look at this code: magento2/app/code/Magento/Checkout/Block/Checkout/LayoutProcessor.php Lines 323 to 339 in 7c81c1d I think you'll need to figure something out, to add the required-entry validation of those 3 billing address fields in there, based on the chosen configuration?
(not 100% sure about this though) |
|
@hostep In our tests it set the correct validation on the checkout without modifying anything, based on the attribute settings. so I think this is not necessary. |
|
Nice work - I believe if you want to increase your chances of a quick merge I suggest taking a look at making the constructor changes here https://github.com/magento/magento2/pull/8519/files#diff-abecee6a6fc7dfb7ec46099d0ffec980R55 use an optional parameter similar to how @dmanners has been doing here https://github.com/magento/magento2/pull/8481/files#diff-ab7a66b8a18582a01b9661fe9270486aR51 |
|
@avstudnitz Thank you for the contribution! I'm verifying it at the moment. |
| * @method string getCity() | ||
| * @method string getTelephone() | ||
| * @method string getCompany() | ||
| * @method string getFax() |
|
@vrann Yes, will do that over the weekend. It's the unit tests, right? |
|
@avstudnitz actually nevermind issues in the unit tests (Travis), it was fast fix and I just did it. |
|
@avstudnitz from the review perspective all the changes looks good and the functionality works perfectly. |
|
Great to hear @vrann! |
|
@avstudnitz thank you for your contribution. PR is merged |
* MAGETWO-64607: Implement custom provider to collect store and system configuration * MAGETWO-64608: Configure store and website reports for data collection * MAGETWO-64612: Implement config for Analytics cron setting * Create wishlist.js * Delete wishlist.js * Update requirejs-config.js * MAGETWO-64607: Implement custom provider to collect store and system configuration * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64629: Add plugin for base url change small refactoring * MAGETWO-64630: Create cronjob that executes update command * MAGETWO-64629: Add plugin for base url change review fixes * MTO-142: [Test] Captcha on front login - Defects fixed. * MTO-142: [Test] Captcha on front login - Defects fixed. * MAGETWO-64630: Create cronjob that executes update command * MAGETWO-63406: [Github] Paypal Payment Order Transaction ID Link will result to 404 not found - Fixed returned link - Fixed unit tests * Update Save.php If quantity is changed using mass action for attribute changes, but no stock item exists for the product, saving the newly created stockItem in StockItemRepository->save($stockItem) returns without saving the stockItem, since $stockItem->getProductId() is null, due to it being added to the array with key '0' (see line 165). To fix this, the array key has been changed to "product_id", such that StockItemRepository successfully creates the stockItem. Also, in my opinion, StockItemRepository->save() should not just return without notice, especially as it already encapsulates the functionality in a try/catch block. Throwing an exception would actually tell the user that something went wrong. * MAGETWO-64630: Create cronjob that executes update command * MAGETWO-64224: Remove usages of AttributeCache from customer module - fixing annotation * MAGETWO-64224: Remove usages of AttributeCache from customer module - making inheritdoc lowercase * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64612: Implement config for Analytics cron setting * MAGETWO-64629: Add plugin for base url change add secure url check * MAGETWO-64629: Add plugin for base url change add secure url check test * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter * MAGETWO-64505: [Integration] Advanced Analytics subscription create API request add data provider * MAGETWO-64505: [Integration] Advanced Analytics subscription create API request * MTO-111: [Test] Update Category if Use Category Flat (Cron is ON, "Update on Save" Mode) - Defects fixed. * MTO-113: [Test] Captcha on admin login - Defects fixed * MAGETWO-64625: Implement API for file downloading by MA allow only secure connections for analytics * MAGETWO-53457: [COMMUNITY] [FEEDBACK] Improve error reporting for failed order placement (checkout) magento#4682 updated unit tests * MTO-142: [Test] Captcha on front login - Defects fixed. * MTO-113: [Test] Captcha on admin login - Defects fixed * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64630: Create cronjob that executes update command * MAGETWO-65047 [GitHub][PR] Refactor contact module magento#8420 - fix code style issues * MAGETWO-65047 [GitHub][PR] Refactor contact module magento#8420 - fix integrity tests issues * MAGETWO-65047 [GitHub][PR] Refactor contact module magento#8420 - fix integration tests * MAGETWO-64902: [GitHub][PR] bug magento#8277 fixing bug with https downloading. magento#8278 * MAGETWO-64775: [GitHub] [PR] Make "is_required" and "is_visible" properties of telephone, company and fax attributes of addresses configurable magento#8519 - fix unit and integration tests * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter * MAGETWO-64625: Implement API for file downloading by MA add base64 encoding for transferring binary vector * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64613: Implement service to enrypt collected data * MAGETWO-64775: [GitHub] [PR] Make "is_required" and "is_visible" properties of telephone, company and fax attributes of addresses configurable magento#8519 - fix unit tests * MAGETWO-64613: Implement service to enrypt collected data * MAGETWO-64609: Extend modules report for data colection * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter - covered skipping already converted data with integration test * MAGETWO-64608: Configure store and website reports for data collection * MAGETWO-64613: Implement service to enrypt collected data * MAGETWO-64505: [Integration] Advanced Analytics subscription create API request -- fix test * MAGETWO-62322: Performance Profile Generator * MAGETWO-62322: Performance Profile Generator * Add correct return type in order service The method return $this. I corrected the doc-block. * MAGETWO-64625: Implement API for file downloading by MA fix tests * MAGETWO-62549: Collect Data by cron and encrypt file -- fix code style * MAGETWO-64625: Implement API for file downloading by MA allow only secure connections for analytics * MAGETWO-62549: Collect Data by cron and encrypt file -- fix code style * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Issue added to variation * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64626: Web API test for file export edit test for run on http * MAGETWO-65006: [GitHub][PR] Keep transparency when resizing images magento#7307 - fix is created based on public pull request magento#7307 by @kassner - closing magento#7307 * MAGETWO-51176: ST compiler supplies ObjectManagerInterface to direct third party dependencies * Fixed Doc Block for the dispatch method of the Rest Controller - provided more information on how dispatch method handles the Request * remove unused ComponentRegistrar instance from being passed to Populator::populateMappings * Fixed return type of OrderRepository::getList * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter - custom converters coverage * MAGETWO-64626: Web API test for file export edit test for run on http * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64626: Web API test for file export edit test for run on http * MAGETWO-64626: Web API test for file export allow only secure connections for analytics * MTO-111: [Test] Update Category if Use Category Flat (Cron is ON, "Update on Save" Mode) - Duplicated new line removed. * MAGETWO-64626: Web API test for file export edit test for run on http * MTO-146: [Test] Create offline Order from "Edit Customer" Admin page - Defects fixed * MAGETWO-64802: Implement corrupted data reporting for fieldDataConverter - custom converters - fixed integration test and removed dependency * MTO-142: [Test] Captcha on front login - Defects fixed. * MAGETWO-64796: Added fixture for Customer module with assigned website * MAGETWO-64601: [Integration] report page API request for Advanced analytics * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-61095: When attempting to place a reorder after a product is disabled, product still gets added to the cart * MAGETWO-64515: change comment in file due to PR risk * MAGETWO-64515: change comment in file due to PR risk * MAGETWO-62168: Improve field data converter logging and error reporting * MAGETWO-62168: Improve field data converter logging and error reporting * MAGETWO-62168: Improve field data converter logging and error reporting * MAGETWO-62168: Improve field data converter logging and error reporting * MAGETWO-62168: Improve field data converter logging and error reporting * MAGETWO-62168: Improve field data converter logging and error reporting
[Spartans] Bugfix Delivery
Fixes #1691.

We added configuration for telephone, fax and company fields in configuration:
You can set them to be optional, required, or not shown at all. All necessary forms have been adjusted.