Herzlich willkommen

Adding the VAT number input field to registration and checkout

Created at: 15 Jun 2015 | Updated at: 12 Jul 2023

Please check if you have enabled this config setting at System->Configuration->Customer Configuration (Show VAT Number on Frontend)

Magento Core VAT field

If this is already the case, it might be that the used template does not support the field. You can add it with the following code to your template files:

At customer registration

<?php if (Mage::helper('customer/address')->isVatAttributeVisible()) : ?>
    <label for="vat_id"><?php echo $this->__('VAT Number') ?></label>
    <div class="input-box">
        <input type="text" name="vat_id" value="" title="<?php echo $this->__('VAT Number') ?>" id="vat_id" class="input-text <?php echo Mage::helper('customer/address')->getAttributeValidationClass('vat_id') ?>">
    </div>
<?php endif; ?>

At cart (estimate shipping and tax)

<?php if (Mage::helper('customer/address')->isVatAttributeVisible()) : ?>
   <?php $vat_id = Mage::getSingleton('checkout/session')->getQuote()->getShippingAddress()->getVatId(); ?>
       <label for="vat_id"><?php echo $this->__('VAT Number') ?></label>
           <div class="input-box">
                 <input type="text" name="vat_id" value="<?php echo $this->escapeHtml($vat_id) ?>" title="<?php echo $this->__('VAT Number') ?>" id="vat_id" class="input-text <?php echo Mage::helper('customer/address')->getAttributeValidationClass('vat_id') ?>">
           </div>
<?php endif; ?>

At checkout (billing address)

<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
    <label for="billing:vat_id"><?php echo $this->__('VAT Number'); ?></label>
    <div class="input-box">
        <input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()); ?>" title="<?php echo $this->__('VAT Number'); ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
    </div>
<?php endif; ?>

At checkout (shipping address)

<?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
    <label for="shipping:vat_id"><?php echo $this->__('VAT Number'); ?></label>
    <div class="input-box">
        <input type="text" id="shipping:vat_id" name="shipping[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()); ?>" title="<?php echo $this->__('VAT Number'); ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
    </div>
<?php endif; ?>
Categories: EU VAT Enhanced (M1)
Tags: VAT field