Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save andrewlimaza/5710646480efd2a866e735bc3daba7f0 to your computer and use it in GitHub Desktop.
Save andrewlimaza/5710646480efd2a866e735bc3daba7f0 to your computer and use it in GitHub Desktop.
Custom tax structure for Paid Memberships Pro where level 1 has no tax and all other levels have 7.25% tax if country is IT (Italy)
<?php
/*
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- Level 1 has no tax applied, all other levels have tax applied.
- Other levels have 22% tax for IT customers only.
- We update the price description to include the tax amount.
*/
function my_pmpro_tax( $tax, $values, $order ) {
//Apply tax to all levels that have chosen Italy as a country.
if(trim(strtoupper($order->billing->country)) == "IT"){
$tax = round((float)$values[price] * 0.22, 2);
}
return $tax;
}
add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
function my_pmpro_level_cost_text($cost, $level) {
//only applicable for levels > 1
if( ! pmpro_isLevelFree($level) ) {
$cost .= ", 22% IVA compresa.";
}
return $cost;
}
add_filter("pmpro_level_cost_text", "my_pmpro_level_cost_text", 10, 2);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment