Util
Utility functions for the VAT plugin.
Tags
Table of Contents
- $eu_vat_rates : mixed
- array_insert_after() : array<string|int, mixed>|bool
- Inserts a new key/value after the key in the array.
- can_reverse_charge_vat() : mixed
- Checks whether reverse charge is supported in a specific country.
- clean() : mixed
- Sanitize anything.
- format_edd_address() : string
- Formats and EDD address array for output
- get_company_vat() : Company_VAT
- Fetches all settings related to Company VAT
- get_company_vat_numbers() : string
- Get the company VAT number(s) for output.
- get_country_for_address() : string
- Return the country to use for the address.
- get_country_for_api() : string
- Return the country to use for the API.
- get_country_list() : array<string|int, mixed>
- Get the list of countries plus our custom ones.
- get_eu_countries() : array<string|int, string>
- Retrieves an array of the EU country codes.
- get_eu_countries_list() : array<string|int, mixed>
- Returns a list of EU countries plus the United Kingdom.
- get_eu_vat_number_prefixes() : array<string|int, string>
- Retrieves an array of EU VAT number prefixes keyed by country code.
- get_eu_vat_rates() : array<string|int, mixed>
- Retrieves an array of the EU VAT rates keyed by country code.
- get_payment_vat() : Payment_VAT
- Retrieves a Payment_VAT object
- get_vat_rate() : float|int
- Get a VAT rate for a specific country code.
- is_edd_active() : bool
- Checks whether the EDD plugin is active.
- is_eu_payment() : bool
- Check if a given payment is from an EU country
Properties
$eu_vat_rates
private
static mixed
$eu_vat_rates
Methods
array_insert_after()
Inserts a new key/value after the key in the array.
public
static array_insert_after(string $key, array<string|int, mixed> &$array, string $new_key, mixed $new_value) : array<string|int, mixed>|bool
Parameters
- $key : string
-
The key to insert after.
- $array : array<string|int, mixed>
-
An array to insert in to.
- $new_key : string
-
The key to insert.
- $new_value : mixed
-
An value to insert.
Return values
array<string|int, mixed>|bool —The new array if the key exists, FALSE otherwise.
can_reverse_charge_vat()
Checks whether reverse charge is supported in a specific country.
public
static can_reverse_charge_vat(string $country_code) : mixed
Parameters
- $country_code : string
Return values
mixed —clean()
Sanitize anything.
public
static clean(mixed $var) : mixed
Parameters
- $var : mixed
-
the thing to sanitize.
Return values
mixed —format_edd_address()
Formats and EDD address array for output
public
static format_edd_address(array<string|int, mixed> $address) : string
Parameters
- $address : array<string|int, mixed>
Return values
string —get_company_vat()
Fetches all settings related to Company VAT
public
static get_company_vat() : Company_VAT
Return values
Company_VAT —get_company_vat_numbers()
Get the company VAT number(s) for output.
public
static get_company_vat_numbers() : string
Return values
string —get_country_for_address()
Return the country to use for the address.
public
static get_country_for_address() : string
Return values
string —get_country_for_api()
Return the country to use for the API.
public
static get_country_for_api([mixed $default = '' ]) : string
Parameters
- $default : mixed = ''
Return values
string —get_country_list()
Get the list of countries plus our custom ones.
public
static get_country_list([mixed $with_moss = true ]) : array<string|int, mixed>
Parameters
- $with_moss : mixed = true
Return values
array<string|int, mixed> —get_eu_countries()
Retrieves an array of the EU country codes.
public
static get_eu_countries() : array<string|int, string>
Return values
array<string|int, string> —get_eu_countries_list()
Returns a list of EU countries plus the United Kingdom.
public
static get_eu_countries_list() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_eu_vat_number_prefixes()
Retrieves an array of EU VAT number prefixes keyed by country code.
public
static get_eu_vat_number_prefixes() : array<string|int, string>
Return values
array<string|int, string> —get_eu_vat_rates()
Retrieves an array of the EU VAT rates keyed by country code.
public
static get_eu_vat_rates() : array<string|int, mixed>
Return values
array<string|int, mixed> —get_payment_vat()
Retrieves a Payment_VAT object
public
static get_payment_vat(mixed $payment_id) : Payment_VAT
Parameters
- $payment_id : mixed
Return values
Payment_VAT —get_vat_rate()
Get a VAT rate for a specific country code.
public
static get_vat_rate(string $country) : float|int
Parameters
- $country : string
Return values
float|int —is_edd_active()
Checks whether the EDD plugin is active.
public
static is_edd_active() : bool
Return values
bool —is_eu_payment()
Check if a given payment is from an EU country
public
static is_eu_payment(int $payment_id) : bool
Parameters
- $payment_id : int