diff --git a/app/code/Magento/Customer/Block/Widget/Taxvat.php b/app/code/Magento/Customer/Block/Widget/Taxvat.php index e35f04f592a43..d117ee7e1b6dd 100644 --- a/app/code/Magento/Customer/Block/Widget/Taxvat.php +++ b/app/code/Magento/Customer/Block/Widget/Taxvat.php @@ -76,4 +76,14 @@ public function getStoreLabel($attributeCode) $attribute = $this->_getAttribute($attributeCode); return $attribute ? __($attribute->getStoreLabel()) : ''; } + + /** + * Get is taxvat visible in register form + * + * @retrun bool + */ + public function isVatVisible(): bool + { + return $this->_addressHelper->isVatAttributeVisible(true); + } } diff --git a/app/code/Magento/Customer/Helper/Address.php b/app/code/Magento/Customer/Helper/Address.php index 74eee759b4abd..74167a8c0eabb 100644 --- a/app/code/Magento/Customer/Helper/Address.php +++ b/app/code/Magento/Customer/Helper/Address.php @@ -33,7 +33,9 @@ class Address extends \Magento\Framework\App\Helper\AbstractHelper const XML_PATH_VIV_TAX_CALCULATION_ADDRESS_TYPE = 'customer/create_account/tax_calculation_address_type'; - const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/create_account/vat_frontend_visibility'; + const XML_PATH_VAT_FRONTEND_VISIBILITY = 'customer/address/taxvat_show'; + + const XML_PATH_VAT_REGISTER_FORM_VISIBILITY = 'customer/create_account/vat_frontend_visibility'; /** * Possible customer address types @@ -387,12 +389,20 @@ public function getTaxCalculationAddressType($store = null) } /** - * Check if VAT ID address attribute has to be shown on frontend (on Customer Address management forms) + * Check if VAT ID address attribute has to be shown on frontend + * (on Customer Address management forms or Customer register form) * + * @param bool $registerFom * @return boolean */ - public function isVatAttributeVisible() + public function isVatAttributeVisible(bool $registerFom = false): bool { + if ($registerFom) { + return $this->scopeConfig->isSetFlag( + self::XML_PATH_VAT_REGISTER_FORM_VISIBILITY, + ScopeInterface::SCOPE_STORE + ); + } return $this->scopeConfig->isSetFlag( self::XML_PATH_VAT_FRONTEND_VISIBILITY, ScopeInterface::SCOPE_STORE diff --git a/app/code/Magento/Customer/view/frontend/templates/widget/taxvat.phtml b/app/code/Magento/Customer/view/frontend/templates/widget/taxvat.phtml index 1551ea9609449..61c288cfba608 100644 --- a/app/code/Magento/Customer/view/frontend/templates/widget/taxvat.phtml +++ b/app/code/Magento/Customer/view/frontend/templates/widget/taxvat.phtml @@ -6,9 +6,13 @@ /** @var \Magento\Customer\Block\Widget\Taxvat $block */ ?> +isVatVisible()): ?>
isRequired() ? ' data-validate="{required:true}"' : '' ?>>
+ + +