Skip to content

Instantly share code, notes, and snippets.

@dparker1005
Last active September 30, 2019 10:05
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dparker1005/9d088fdab73381396c8e7cc90cdd124c to your computer and use it in GitHub Desktop.
Save dparker1005/9d088fdab73381396c8e7cc90cdd124c to your computer and use it in GitHub Desktop.
Based off of https://www.paidmembershipspro.com/custom-tax-structure-using-the-pmpro_tax-hook/ to add a flat tax rate to all purchases. Make sure to change tax rate before use.
<?php
/*
Custom Tax Example.
- Requires PMPro 1.3.13 or higher.
- Leave the tax fields blank in the payment settings.
- We update the price description to include the tax amount.
*/
function my_pmpro_tax($tax, $values, $order)
{
$tax = round((float)$values[price] * 0.055, 2);
return $tax;
}
add_filter("pmpro_tax", "my_pmpro_tax", 10, 3);
function my_pmpro_level_cost_text($cost, $level)
{
$cost .= " Customers will be charged 5.5% tax.";
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