Capture VAT numbers on Cart page

You can add the VAT registration number field to the cart page, so that your customers can enter their VAT registration numbers just before the checkout.

Customers without a customer account or those not logged in will need to enter their email address.

Shopify cart page VAT number

Example of a cart page with the VAT registration number field

VAT registration numbers will be stored in your Shopify admin as cart attributes. Sufio will automatically validate VAT numbers and set business customers as tax-exempt when applicable, as well as include them on your invoices.

To add the email and VAT registration number field to the cart page:

  1. In your Shopify admin, go to the Online Store → Themes page. 
  2. Click the Actions button, then click Edit code.
  3. Select cart.liquid (or cart-template.liquid) in the left sidebar. You might use the upper search bar for a faster search. 
  4. Insert the following code snippet inside the <form>. A good place for the field is just before the Check out button. 

<!-- Shopify shopping cart -- capture and validate VAT numbers and set business customers as tax exempt when applicable. Used by Sufio for Shopify ( -->
<div class="vat-fields">
  <div class="vat-email">
    {% if %}
    <input type="hidden" id="vat_email" name="attributes[Email]" value="{{ }}" />
    {% else %}
    <label for="email">Email</label>
    <input type="text" id="vat_email" name="attributes[Email]" value="{{ cart.attributes['Email'] }}" data-error-message="Please enter your email." />
    {% endif %}

  <div class="vat-reg-number">
    <label for="vat_reg_no">VAT Registration Number</label>
    <input type="text" id="vat_reg_no" name="attributes[VAT Registration Number]" value="{{ cart.attributes['VAT Registration Number'] }}" />

<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function(event) {
    $('input[name=checkout],button[name=checkout],input[name=goto_pp],button[name=goto_pp]').on("click", function() {
      // If enabled, customers will be unable to submit VAT numbers without entering their emails
      var check_email = true;  

      var submit_button = $(this);
      var email_input = $('input#vat_email');
      var vat_input = $('input#vat_reg_no');
      var email = email_input.val();
      var vat_no = vat_input.val();

      if ((email) && (vat_no)) {
        // Submit email and VAT number for validation and set customer as tax exempt
          type : "GET",
          dataType: "jsonp",
          url: "/apps/sufio/customer-vat/",
          data: { email: email, vat_no: vat_no },
          success: function(data) {
            // Proceed to checkout after successfully sending the VAT number
            var form = submit_button.parents('form');
            form.attr('action', form.attr('action') + '?checkout[email]=' + encodeURIComponent(email));
      } else if ((vat_no) && (check_email)) {
        // Missing email - display error message
        email_input.prop("required", "required");
        return false;
      } else {
        return true;

      // Proceed to checkout after one second
      setTimeout( function () { 
      }, 1000);

      return false;

Please note that if your store uses cart drawer (also called ajax cart), this code snippet needs to be added to a different file than cart.liquid. In most cases, it needs to be added to ajax-cart-template.liquid file.

View VAT Exemptions

When your business customer enters a VAT registration number on the cart page, a VAT exemption request is listed on the View VAT Exemptions page in your Sufio account.

This page includes all successful and unsuccessful exemption requests made on your online store. Filtering by their statuses permits you to review and troubleshoot the VAT exemption requests effectively, if necessary.

To access the View VAT Exemptions page:

  1. In your Sufio account, go to the Settings → Taxes page.
  2. Click on View VAT Exemptions.

To learn more on how to use this page, have a look at our View VAT Exemptions article.

Need help?

Do you need help with inserting the code snippet into your Shopify store theme code? We'll be happy to assist! Please contact our support team.