1. Knowledge Base
  2. Easy Digital Downloads EU VAT
  3. Developer Documentation

Hooks and filters

The Easy Digital Downloads EU VAT plugin comes with a number of filters which allow you to customize its behavior.

Please note that this code is aimed at developers and if you don’t know how to use it then you should ask your developer. If you don’t have one, we recommend posting a job on Codeable. We have partnered with them to provide plugin customizations for our customers.

Need professional assistance?
We've partnered with Codeable to provide our customers with expert help if required.

Filters

edd_vat_current_eu_vat_rates

Filter the current list of EU VAT rates. The rates are supplied as an array, keyed by country code and mapped to the corresponding VAT rate, e.g. 'UK' => 20.0. Rates should be supplied as percentages, so 20.0 for 20%.

Arguments

array $vat_rates – The VAT rates.

Return

array

edd_vat_can_reverse_charge_vat

Whether the VAT can be reverse charged for a given country. Changing this overrides the logic built into the plugin, which is based on whether the country is in the EU and the plugin setting to reverse charge in your base country.

Arguments

boolean $can_reverse_charge – Whether the VAT can be reverse charged
String $country_code – The user’s billing country

Return

boolean

edd_vat_purchase_receipt_customer

This filter can be used in your theme or plugin to format the customer details output on the purchase confirmation page.

Arguments

String $customer_details – The formatted output
String $customer_name – The customers name entered on checkout
String $customer_address – The customers address entered on checkout
String $vat_number – The customers VAT number entered on checkout.

Return

String – The formatted customer details

edd_vat_purchase_receipt_company

This filter can be used in your theme or plugin to format the company details output on the purchase confirmation page.

Arguments

String $company_details – The formatted output
String $company_name – The customers name entered on the settings page.
String $company_address – The customers address entered on the settings page.
String $vat_number – The customers VAT number entered on the settings page.

Return

String – The formatted company details

edd_vat_address_format

This filter can be used in your theme or plugin to change the formatting of the VAT address output for both customers and companies.

Arguments

String $formatted_adresss – The formatted address
Array $address – The unformatted address array

Return

String – The formatted address

edd_vat_number_check

The result from the VAT check.

Arguments

Barn2\Plugin\EDD_VAT\VAT_Check_Result – The VAT check result object
String $vat_number – The VAT number that was checked
String $country_code – The country code

Return

Barn2\Plugin\EDD_VAT\VAT_Check_Result

edd_vat_checkout_vat_field_location

Change the position of the VAT field on the checkout page. Expects a hook name for the EDD checkout – the return value of this filter is passed to add_action() to add the field to the checkout.

Arguments

String $location – The hook name to use to add the VAT field. Default: edd_cc_billing_bottom

Return

String

edd_vat_checkout_vat_field_description

The label for the VAT field on the checkout.

Arguments

String $desc – The label. Default: Enter the VAT number of your company.

Return

String

edd_vat_checkout_vat_number_placeholder

The placeholder text for the VAT input box on the checkout.

Arguments

String $placeholder – The placeholder text.

Return

String

edd_vat_checkout_vat_field_html

The HTML for the VAT field used on the checkout.

Arguments

String $html – The HTML for the VAT field.
Barn2\Plugin\EDD_VAT\VAT_Check_Result $vat_details – The current VAT result.
boolean $is_reverse_charged – Whether the cart is reverse charged or not.

Return

String

edd_vat_checkout_vat_result_html

The HTML for the VAT result shown on the checkout.

Arguments

String $html – The HTML for the VAT result.
Barn2\Plugin\EDD_VAT\VAT_Check_Result $vat_result – The result of the VAT check.
boolean $is_reverse_charged – Whether the cart is reverse charged or not.

Return

String

edd_vat_cart_label_reverse_charged

The label used in the EDD cart to denote the cart tax has been reverse charged for VAT. This is shown in the “Tax” column in the cart. The result is passed to sprintf() and expects one %s token.

Arguments

String $html – The reverse charged label. %s in the string is replaced by the current cart tax. Default: "[VAT reverse charged] %s".

Return

String

edd_vat_reverse_charge_vat_rate

The tax rate to apply when the cart has been reverse charged. This happens when the customer has entered a valid VAT number for their company within the EU.

Arguments

float $reverse_charge_rate – The rate to apply when reverse charged. Default: 0.0
String $country – The user’s billing country code (e.g. US)
String $state – The user’s billing state

Return

float (between 0.0 and 1.0)

edd_vat_apply_eu_vat_automatically

Whether or not to apply EU VAT automatically during checkout.

Arguments

boolean $apply_automatically – Whether to apply VAT automatically. Default: true

Return

boolean

edd_vat_check_result_text

The text shown after a VAT number has been checked by the customer during checkout.

Arguments

String $vat_result_text – The message shown on the checkout (e.g. "The VAT number is invalid")
Barn2\Plugin\EDD_VAT\VAT_Check_Result $vat_result – The VAT result object.

Return

String

edd_vat_check_result_class

The CSS class applied to the <span> element that wraps the VAT result shown beneath the VAT field on the checkout.

Arguments

String $result_class – The CSS class. Will be either edd-vat-check-success or edd-vat-check-error
Barn2\Plugin\EDD_VAT\VAT_Check_Result $vat_result – The VAT result object.

Return

String

edd_vat_error_code_to_string

The result of converting the VAT error code to a string.

Arguments

String $error – The error text.
int $error_code – The error code – see Barn2\Plugin\EDD_VAT\VAT_Check_Result.

Return

String

edd_vat_register_pdf_template_callback

If using the PDF Invoices extension. Whether to register the VAT callback to add the VAT details to the PDF invoice.

Arguments

boolean $register_callback – Whether to add the callback. Default true
String $template – The current PDF template name.

Return

boolean

edd_vat_pdf_template_callback_<template>

If using the PDF Invoices extension. The callback to use to output the VAT details on the PDF invoice.

Arguments

callback – The callback to use. Defaults to the function supplied in the plugin.

Return

callback

Still need help?
If searching the knowledge base hasn't answered your question, please contact support.