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

Actions 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.

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%.

edd_eu_vat_uk_hide_checkout_input

Optionally hide the VAT number field for United Kingdom on checkout. e.g.add_filter( 'edd_eu_vat_uk_hide_checkout_input', '__return_true' ); to disable.

Arguments

boolean $hidden - Whether the field is hidden, default 'false'.

Return

boolean

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

edd_vat_export_vat_amount_total

Applies to the EU VAT report (Downloads -> Reports -> Export). Filters the payment total for an EDD payment before it's added to the overall total for the relevant EU country. This can be useful if you need to convert the purchase currency to your local currency for reporting.

Arguments

float $total - The payment total in the purchase currency.
int $payment_id - The payment ID for the purchase.
EDD_Payment $payment - The EDD payment object.

Return

float

edd_vat_export_vat_tax

Applies to the EU VAT report (Downloads -> Reports -> Export). Filters the VAT amount for an EDD payment before it's added to the total VAT for the relevant EU country. This can be useful if you need to convert the purchase currency to your local currency for reporting.

Arguments

float $tax - The VAT total in the purchase currency.
int $payment_id - The payment ID.
EDD_Payment $payment - The EDD payment object.

Return

float

edd_vat_export_vat_ec_sales_amount

Applies to the EC Sales List report (Downloads -> Reports -> Export). Filters the amount (value of supply) for an EDD payment before it's added to the EC Sales List. This can be useful if you need to convert the purchase currency to your local currency for reporting.

Arguments

float $total - The payment total in the purchase currency.
int $payment_id - The payment ID.
EDD_Payment $payment - The EDD payment object.

Return

float

edd_vat_export_vat_ec_sales_amount_rounding

Change the rounding method of payments in the EC Sales reports. The default option rounds any decimals greater than or equal to 0.5 up, and those below 0.5 down. You can change this to always round up or down.

Arguments

boolean $mode - round_up, round_down, default.

Return

string $mode - round_up, round_down, default.

edd_vat_export_vat_ec_sales_vat_number

Filter for the VAT number which is output for payments in the EC Sales reports. You can use this toapply any desired formatting to the VAT numbers.

Arguments

string $vat_number - The VAT Number.

Return

string $vat_number

edd_vat_hide_edd_sl_upgrade_notices

By default the EDD Reccuring notices for renewing or upgrading a license show the incorrect price (including tax) after a VAT number is supplied.

EDD EU VAT hides these after successful VAT number submission on checkout to avoid showing a price inconsistency.

You can use this filter to stop hiding them. e.g.add_filter( 'edd_vat_hide_edd_sl_upgrade_notices', '__return_false' ); to show them again.

Arguments

boolean $hidden - Whether the notices are hidden is hidden, default 'true'.

Return

boolean

edd_vat_invoice_address_country_code

In some cases, in order to validate VAT details you may need to select the "EU MOSS Number" option as a country via the EDD EU VAT settings panel. When selecting this option, the country publicly visible in invoices and receipts will change to "EU MOSS Number" too.

You can use this filter to adjust the country code used for retrieving EU company details. By default, EDD EU VAT uses the filter internally with a priority of 10 and falls back to the Store base country code.

Arguments

string $code - Country code selected via the EDD EU VAT settings panel.

Return

string

edd_vat_recurring_insert_subscription_payment_id

You can use this filter to adjust the the payment ID number that is used to update the VAT metadata when a new recurring subscription from the EDD Recurring Payments extension is created.

Arguments

string|int $payment_id - ID of the payment.
EDD_Payment $payment - The payment object.
EDD_Subscription $subscription - The subscription object.

Return

string|int

Related Articles

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