magento:euvat:template

EuVat Template Blocks

This section related to Magento 1, for Magento 2 use the configuration options of EU VAT.

To use the EuVat template blocks that come with the extension, you need to update your stores template files as documented below.

When modifying your stores template files and testing the changes please ensure that:

  • Your stores cache is disabled, such that changes to your template files are reflected immediately
  • The template files of the actual used template are being modified, and not just the default template files which may be overridden by the active template.
  • We also recommend to copy the default template files of EuVat to your actual used template path to protect customizations on the EuVat templates from future updates.



When using Magento 1.6, 1.7 or above some template files are made persistent and are found in the persistent directory of your themes template directory structure. So if you experience that a template file change does not propagate to the store design, please look into the persistent directory of your theme and use the template file there for the modification.

Or you may need to copy the related default template file from the persistent directory from default/default/template or base/default/template to the persistent directory of your theme being used if it is not there already.



Starting with Magento 1.7 you may need to set additional configuration options to enable display of the Taxvat Input field which is replaced by the EU VAT-ID input field of EuVAT for Magento. See here for these details...

EuVat delivers with a input box for the Tax/VAT Number that allows to Validate any entered VAT Number:



The Widget also features a drop-down country selection that automatically is adding the VAT ID country related prefix to the input field, as well as a syntax check of the EU VAT-ID as validation directly on the form field (in addition to the EU VIES validation):



With having the configuration option VAT-ID has to match Address Country set to Yes also a form validation is performed verifying that the EU VAT-ID belongs to the current selected Address Country:



The template for this input box is located here, in case you are using a different template from the Magento default copy the Widget file to the same location in your templates path:

Location of the EuVat-VAT Number Input Box Widget

app/design/frontend/default/default/template/euvat/widget/taxvat.phtml


To use this input box, instead of the Magento default one, modify the following template files:

template/customer/form/register.phtml

// Around Line 65 replace this:
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
 
// With this:
<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat') ?>
 
// Or to use the 'wide' version of the TAXVAT input field (usable in all forms):
<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat_wide') ?>

template/customer/form/edit.phtml

// Around Line 52 replace this:
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
 
// With this:
<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat') ?>

template/checkout/onepage/billing.phtml

// Around Line 89 replace this:
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
 
// With this:
<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat') ?>


You may need also to enable the Tax/Vat field in System » Configuration » Customer Configuration » Name and Address Options » Show Tax/VAT Number to display the Tax/Vat field in the template.

For the 'Validate' function of this input field to work, your Magento installation requires to meet the Prerequisites described here. The validation may require a little time to complete, based on the load of the external site being used. If the validation does not show a result then the server, where your Magento installation is located on, may not support communication with the external VIES site.



If your template file does not show the above code lines, this here is the full block that might work in your template then. Some modification of the HTML tags may be required, depending on the actual template file:

template/checkout/onepage/billing.phtml

<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat') ?>
<?php if ($_taxvat->isEnabled()): ?>
  <li>
      <?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
  </li>
<?php endif ?>



Changing the default Widget Template

To change the default Widget Template (euvat/widget/taxvat.phtml) to some other template file, or a customized template, use the setTemplate as shown here to set a different template file for the Widget:

<?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat')->setTemplate('euvat/widet/taxvat/wide.phtml') ?>



There are the following customized Widget Templates included in the EuVAT extension for the VAT ID input field:

  • To hide the VAT ID Validation button if there is no VAT ID entered:
    <?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat')->setTemplate('euvat/widet/taxvat-autohide.phtml') ?>


  • To show the VAT ID input field only for selected EU Address Countries other than the current default Store Country (Validation button also is hidden if there is no VAT ID entered):
    <?php $_taxvat = $this->getLayout()->createBlock('euvat/widget_taxvat')->setTemplate('euvat/widet/taxvat-country') ?>



Behaviour of this field

This field behaves as the default Magento Taxvat entry field, and its behaviour is controllable in System » Configuration » Customer Configuration » Name and Address Options » Show Tax/VAT number:

  • No …the field is hidden
  • Optional …Entry of the VAT number is optional
  • Required …Entry of the VAT number is required



Validation Messages on failures


This validation message indicates that the Page Session has expired. For the online validation a form security key is generated for the current Visitor Session, this session may time out and the related security key becomes outdated. That is a security measure to block automated requests from other systems.
With this message the Visitor is adviced to reload the current page and by it to refresh his Session.



This validation message indicates that there is a communication failure with the EU VIES site, where the validation takes place. That may be caused by your server and a related firewall, or the EU VIES service being temporarily out of service or overloaded with requests. See also here for more on this.


EuVat delivers with a template block, showing the current Tax/VAT Status to your customers:


This block is also able to show a link to the description of correct number format for the EU VAT Number, the related configuration setting to enable or disable the display of this link is "Show Link to EU VAT Number Pattern Explanation".
EuVat delivers with a Widget for the Customer Pages located by default in the following path:

Location of the EuVat-Status Customer Widget

app/design/frontend/default/default/template/euvat/widget/euvatstatus.phtml


In case you are using a different template from the Magento default, copy the Widget file to the same location in your templates path:

Target path for Widget file when using a non-default template

app/design/frontend/default/<your template>/template/euvat/widget



To add the EuVat Tax Status Widget into any page of your Magento Template use:

EuVat Tax Status Widget code for template files

<?php
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', '...block-name...');
	echo $_euvat->toHtml();
?>


Depending on the template page where the EuVat Tax Status Widget is used, define the '…block-name…' to tell the widget the page it is included in. Use the prefix 'euvat_widget_' plus the path and name of the template file as shown for these pages:

  • euvat_widget_customer_form_edit - When used on the Customer Edit Account form
  • euvat_widget_customer_form_register - When used on the Customer Register Account form
  • euvat_widget_checkout_cart - When used on the Cart page
  • euvat_widget_checkout_onepage_billing - When used on the Onepage Checkout billing address page
  • euvat_widget_checkout_onepage_review_info - When used on the Onepage Checkout order review page
  • euvat_widget_use_customer - When used anywhere else in your template and to force to use current customer data
  • euvat_widget_use_quote - when used anywhere else in your template and to force to use current quote (i.e. cart) data



If you leave '…block-name…' empty, EuVat will use the current Customer Data (if logged in) for the Tax Status messages, with the '…block-name…' defined the widget will be able to distuingish between the Checkout Process and other pages of your Shop to either use the current Quote or Customer for the Tax Status messages.

The default messages of the EuVat Status Widget do not find any explanation if VAT is applied to orders or not. That because at point of delivery we do not know which Tax Rules you will apply to your store. You may want to add wording for the different Customer Groups (or Tax Classes) if VAT is charged or not by customizing the messages of this Widget.

To customize, translate, add or reduce the messages of this EuVat Status Widget create (or use a existing) Language File in your templates locale directory in a subdirectory named with the respective Language Code.

Name the file customized Language File translate.csv.

This language file is to be a Text File, similar to the System Language Files located in app/locale with comma-separated content.

As source of the messages you may use the German Language File of EuVat, located in app/locale/de_DE/Pisc_Euvat.csv. Copy the messages into translate.csv which you wish to customize for your template and change the second definition. Leave the first definition (before the comma) in takt, otherwise the translation function will be unable to find the customized message content.

Example for 'translate.csv'

"Tax/VAT number","EU VAT Number"
"We have you identified as EU Enduser.","We have you identified as EU Enduser, VAT is applied to your orders. To become VAT excempt, please provide your valid EU VAT Identification in the Tax/VAT field."
"We have you identified as non-EU Customer.","We have you identified as non-EU Customer, no VAT is applied to your orders."



To add this Widget to your Frontend Template, see the following examples below:
(all file paths shown are relative to app/design/frontend/…/<your template>)

Adding the VAT ID to the Customer Account Dashboard

Modify design/frontend/…/template/customer/account/dashboard/info.phtml to add the VAT ID to the customers Overview Page:



template/customer/account/dashboard/info.phtml

        <p>
            <?php echo $this->htmlEscape($this->getCustomer()->getFirstname()) ?>
            <?php echo $this->htmlEscape($this->getCustomer()->getLastname()) ?><br/>
            <?php echo $this->htmlEscape($this->getCustomer()->getEmail()) ?><br/>
            <a href="<?php echo $this->getChangePasswordUrl() ?>"><?php echo $this->__('Change Password') ?></a>
        </p>
<?php 	/*
	 * Around line 39: Added to show VAT ID
	 */  ?>
        <p>
            <?php echo $this->__('VAT Identification:').'&nbsp;'.$this->htmlEscape($this->getCustomer()->getTaxvat()) ?>
        </p>



Adding the EuVat Widget to the Edit Account Information page

Modify design/frontend/…/template/customer/form/edit.phtml to add the EuVat Widget to the Customer Edit Account Information page:


template/customer/form/edit.phtml

<fieldset class="group-select">
...
...
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
<?php if ($_taxvat->isEnabled()): ?>
        <li><?php echo $_taxvat->setTaxvat($this->getCustomer()->getTaxvat())->toHtml() ?></li>
<?php endif ?>
 
    </ul>
<?php
        /*
         * ---- This here includes the EuVat Tax Status Widget ---
         */
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', 'euvat_widget_customer_form_edit');
	echo $_euvat->toHtml();
?>
</fieldset>



Adding the EuVat Widget to the Create An Account page

Modify design/frontend/…/template/customer/form/register.phtml to add the EuVat Widget to the Create An Account page:


template/customer/form/register.phtml

    <fieldset class="group-select wide">
  ...
  ...
<?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
<?php if ($_dob->isEnabled()): ?>
            <li><?php echo $_dob->setDate($this->getFormData()->getDob())->toHtml() ?></li>
<?php endif ?>
<?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
<?php if ($_taxvat->isEnabled()): ?>
            <li><?php echo $_taxvat->setTaxvat($this->getFormData()->getTaxvat())->toHtml() ?></li>
<?php endif ?>
        </ul>
<?php
        /*
         * ---- This here includes the EuVat Tax Status Widget ---
         */
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', 'euvat_widget_customer_form_register');
	echo $_euvat->toHtml();
?>
    </fieldset>



Adding the EuVat Widget to the Shopping Cart page

Modify design/frontend/…/template/checkout/cart.phtml to add the widget to the Shopping Cart page:


template/checkout/cart.phtml

<div class="cart-collateral-block">
...
<?php
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', 'euvat_widget_checkout_cart');
	echo $_euvat->toHtml();
?>
    </div>
</div>



Adding the EuVat Widget to the Billing Address page in the Onepage Checkout

Modify design/frontend/…/template/checkout/onepage/billing.phml to add the widget to the Billing Address page in the Onepage Checkout:


template/checkout/onepage/billing.html

<form id="co-billing-form" action="#">
...
    <?php if ($this->canShip()): ?>
        <p>
        ...
        </p>
    <?php else: ?>
        <p class="no-display"><input type="hidden" name="billing[use_for_shipping]" value="1" /></p>
    <?php endif; ?>
</form>
<?php
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', 'euvat_widget_checkout_onepage_billing');
	echo $_euvat->toHtml();
?>
This page block is not always updated by the browser client. So it may happen that the shown EuVat status message does not fit the current entries of the Billing Address. Especially if a customer is registering during the Checkout, or is going back from the Order Review to modify his Billing Address data.
Because of this we advice to show the EuVat Widget in the Order Review as that page block is always updated by the browser client and Magento.



Adding the EuVat Widget to the Order Review page in the Onepage Checkout

Modify design/frontend/…/template/checkout/onepage/review/info.phtml to add the widget to the Order Review of the Onepage Checkout:


template/checkout/onepage/review/info.phtml

<table cellspacing="0" class="data-table" id="checkout-review-table">
...
...
    <?php echo $this->getChildHtml('totals'); ?>
    <tbody>
    <?php foreach($this->getItems() as $_item): ?>
        <?php echo $this->getItemHtml($_item)?>
    <?php endforeach ?>
    </tbody>
</table>
<?php
	$_euvat = $this->getLayout()->createBlock('euvat/widget_euvatstatus', 'euvat_widget_checkout_onepage_review_info');
	echo $_euvat->toHtml();
?>



EuVat is designed to take the Tax/Vat Id and the Billing Address Country to determine the Tax/Vat status. Therefore, and to be compliant with billing and book-keeping regulations, we advice to let your customers register or create new accounts only with entering their Billing Address.

To enable this, the following Template Files may require modifications as shown here:

template/customer/form/register.phtml

<?php
/**
 * Create account form template
 *
 * @see Mage_Customer_Block_Form_Register
 */
 
// Enable the Address Fields
$this->setShowAddressFields(true);
?>



Alternatively you may comment out the following lines:

template/customer/form/register.phtml

// Around Line 75: Comment out the following:
 
<?php // if($this->getShowAddressFields()): ?><br/>
    <input type="hidden" name="create_address" value="1"/>
    <fieldset class="group-select wide">
        <div class="head-alt2">
            <h4 class="title"><?php echo $this->__('Address Information') ?></h4>
        </div>
 
// Around Line 131: Comment out the following:
 
    </fieldset>
    <input type="hidden" name="default_billing" value="1"/>
    <input type="hidden" name="default_shipping" value="1"/>
<?php // endif; ?>
    <fieldset class="group-select wide">



EuVat offers to add Email Text Blocks to your transactional emails, with content depending on the customers EuVat Status. To add this block, add the following directive into the Email Template of your Transactional Email. At the position where you want the Email Text to appear:

{{block type="euvat/email_text" area="frontend" template="euvat/email/text.phtml" order=$order}}


This Block shows the Email Text as defined in the EuVat Settings...
Allowing to add wording such as:

  • VAT excempt as transaction is between Businesses within the European Union
  • or similar….



To modify the Email Block, modify its template file located per default in app/design/frontend/default/default/template/euvat/email/text.phtml. In that folder there are also other block templates to be used alternatively or as template to create your own.

Example

Open the Email Template of your choice using System » Transactional Emails, or add a Magento Default Email Template, and add the Email Block into your Email Template:

Email Template Example (Order Invoice)

<style type="text/css">
    body,td { color:#2f2f2f; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; }
</style>
 
<div style="font:11px/1.35em Verdana, Arial, Helvetica, sans-serif;">
<table cellspacing="0" cellpadding="0" border="0" width="98%" style="margin-top:10px; font:11px/1.35em Verdana, Arial, Helvetica, sans-serif; margin-bottom:10px;">
<tr>
...
...
 
                    {{layout area="frontend" handle="sales_email_order_invoice_items" invoice=$invoice order=$order}}
 
                    {{block type="euvat/email_text" area="frontend" template="euvat/email/text.phtml" order=$order}}
 
                    <p>{{var comment}}</p>
                    <p>
                        Thank you again,<br/><strong>{{var order.getStoreGroupName()}}</strong>
                    </p>
                </td>
            </tr>
        </table>
    </td>
</tr>
</table>


This example is allowing to add the EuVat Tax Status wording from its settings to the Order Invoice Email Template, right after the invoiced items list. Use this to add any required text to the Invoice (or any other transactional Email) that is required by the Tax Status of your customer.

The display of the Tax Summary is controlled in your Frontend Template. To always show the Tax Summary the following frontend template files require modification:

template/checkout/total/tax.phtml

<?php global $taxIter; $taxIter++; ?>
<?php // Line 2: Modified to always show the Tax Summary, also for zero tax: ?>
<?php // if ($this->helper('tax')->displayFullSummary() && $this->getTotal()->getValue()!=0): ?>
<?php if ($this->helper('tax')->displayFullSummary()): ?>
<?php $isTop = 1; ?>
 
// Around Line 32 change to:
<?php /* if ($this->helper('tax')->displayFullSummary() && $this->getTotal()->getValue()!=0): */ ?>
<?php if ($this->helper('tax')->displayFullSummary()): ?>


Also configure Magento to show the Tax Summary:

On Magento 1.3.2.4: System » Configuration » Tax » Display: Display Zero Tax Subtotal » Yes
On Magento 1.4.0.x: System » Configuration » Tax » Shopping Cart Display Settings: Display Zero Tax Subtotal » Yes



EuVat delivers with language files for English (en_US) and German (de_DE). The language files are located in:

EuVat Translation Files

locale/en_US/Pisc_Euvat.csv
locale/de_DE/Pisc_Euvat.csv



To customize the default Messages, you may put the language file entries to be customized into the customized language file of your Frontend Template:

Customized Translations for your Template

app/design/frontend/default/<your-template>/locale/en_US/translate.csv
app/design/frontend/default/<your-template>/locale/de_DE/translate.csv