Last active
May 31, 2023 13:25
-
-
Save wpfullstripe/9435046a833852f4d83c3d2c1ccb9ab6 to your computer and use it in GitHub Desktop.
The fullstripe_determine_tax_label Wordpress filter
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* A 'fullstripe_determine_tax_label' filter hook example for WP Full Pay. | |
* | |
* @param string $label The tax label returned by the previous filter instance. | |
* @param array $params with the following keys: | |
* taxableAmount => The net payment amount, in cents. | |
* amount => The tax amount, in cents. | |
* inclusive => Boolean value indicating whether the tax amount is included in the product price. | |
* taxabilityReason => Taxability reason, see https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-tax_amounts-taxability_reason for more information, | |
* country => The buyer's uppercase ISO country code. | |
* state => The buyer's state or region. Applicable only in case of US and Canada. | |
* postalCode => The buyer's state or region. Applicable only in case of US and Canada. | |
* taxIdType => The buyer's tax id type. It's set only when the buyer's tax information is collected, otherwise null. | |
* taxId => The buyer's tax id. It's set only when the buyer's tax information is collected, otherwise null. | |
* | |
* @return string Tax label | |
*/ | |
function determineTaxLabel( $label, $params ) { | |
$result = $label; | |
$euCountries = array('LU', 'MT', 'CY', 'DE', 'RO', 'AT', 'EE', 'FR', 'SK', 'SE', 'BE', 'BG', 'CZ', 'ES', 'NL', | |
'LT', 'LV', 'IT', 'PT', 'SI', 'IE', 'PL', 'FI', 'GR', 'HR', 'DK', 'HU'); | |
$country = $params['country']; | |
if ( array_search( $country, $euCountries)) { | |
$result = 'VAT'; | |
} | |
return $result; | |
} | |
add_filter('fullstripe_determine_tax_label', 'determineTaxLabel', 10, 3 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment