The pmpro_tax filter hook allows you to add custom tax amounts to orders with PMPro. In this guide, I’ll cover one of the most common methods of handling taxes that we see for our customers. The method includes checks for the user to choose a region as well as region validation on their billing address.


Overview of Custom Tax Functionality

  1. Add a checkbox at checkout for users to self identify themselves from a certain region.
  2. Add an extra check at checkout to apply tax if the billing address is from a certain country and/or region.
  3. If the checkbox or the address check matches, apply a certain tax rate at checkout.
  4. Update the level cost text to communicate the appropriate tax information.

Here is a plugin that does just that. Just replace the country and region names, tax amount, and other checks in the code below and this should work for most cases where you need to charge tax for customers from a single region only.


The Code Recipe

This code recipe requires a PMPro Plus Account or higher.

View Membership Options

Adding the Recipe to Your Website

You can add this recipe to your site by creating a custom plugin or using the Code Snippets plugin available for free in the WordPress repository. Read this companion article for step-by-step directions on either method.

Looking for the best solution to add and itemize a single GST (Canadian Goods and Service tax) on total value of purchases. We use PayPal gateway as well as checks. The invoice must separate the tax on the invoice. With PayPay we can set the rate but then the checks cause a issue.

Will the propm-tax pluggin itemize the invoice and forward the cost plus taxes to Paypal that we can take the clear the tax setting on PayPal and have an invoice for checks and paypal with the taxes showing

Thanks

Hello. I am only at intermediate level with WordPress and Paid Merbership Pro.
Where and how do we add this code (.php) for taxation exactly?

Thanks,
Guy

Hello, we are running a site for a no profit organization and need not to apply any tax to the price, is there a way to just get rid of taxes calcutation, despite of regiorn of country or so?
Thank you.

Mhm.
If I get this well, using this filter I add tax to the price?
Meaning I would need to set price without tax and then modify them with this filter to add the tax?

Or is there another way to calculate tax out of the price?

I gave up on this plugin, chill986. They really do not understand the concept of taxation outside the US, as most membership plugins for WordPress, actually. You could try WooCommerce. It is a horrible system to work with but it handles taxation properly (if you buy the correct add-ons).

If you are a business in Canada and have customers across Canada, you have to be able to charge the applicable HST + PST for each province. So that means there are a number of different tax rates that must be considered depending upon what province the customer is in. The solution above only works for ONE province. Has anyone written the code to take the ‘Province’ variable (and if it is a US state or anywhere other than a Canadian province, apply 0 tax) and apply the appropriate tax?

I’ve asked the same question chili986 in the forums – you might want to follow it there. This is a good plugin, but has many things that really should be in the core, including Canadian, UK and Australian taxes. It has almost 400 posts with code snippets, so I’m afraid this approach (plugin + code snippets) has gotten too much for non-developers like me to wrestle with. I will probably, as Jason suggested in a reply to a post by me, go back to using S2Member. Pity.

I have a similar problem – I need to be able to apply a variable sales tax depending upon what province in Canada the customer is from.

Hello,

just bought the pro version, hoped to get a solution for adding tax.
For a plugin like yours (really enhanced) I cannot believe that there is no option available for adding EU tax.
In addition to that there must be a setting for a tax setting for all levels and countries, e.g. ANY level and country (ALL) pay xx,xx % tax.

Is there any chance to get this solved (without coding in my side, of course)?

Greetings, Chris

Chris, can you open a post in the member forums? Can you share which country you are in and what taxes are applicable? We should be able to help you out with minimal coding on your end.

I’ve found a solution – rather than filtering `pmpro_tax` (which looks to just add tax onto the total), I’ve instead added a tax element onto the subscription object. This is likely to be a Stripe-specific solution, so I think that the original problem still needs addressing, but this works in my case for 20% UK VAT:

`// Update the tax calculation if buyer is in the UK
function customtax_region_tax_check()
{
// check if a country is set. If it is and the country is GB, then add on VAT
if(isset($_REQUEST[‘bcountry’]) && $_REQUEST[‘bcountry’] == ‘GB’)
{
//update the session var
$_SESSION[‘bcountry’] = $_REQUEST[‘bcountry’];

// Add VAT
add_filter(‘pmpro_stripe_create_subscription_array’, function($subscription){
$subscription[‘tax_percent’] = 20;
return $subscription;
}, 20);
}
}
add_action(“init”, “customtax_region_tax_check”);
`

How about adding the tax specified to PayPal as well? It doesn’t do that at the moment with anything in this blog post or the comments as far as I’ve found.

Hi Jason, did you implemented a real solution for the stripe/tax problem until now?
In Stripe dashboard it shows this POST request:
{
“amount”: “10591”,
“currency”: “eur”,
“customer”: “xXx”,
“description”: “Order #4D1CF01AE3, xXx”
}

If you already fixed it, there seems to be a problem with update the fixed file from my pmpro installation.
It would be nice to hear from you…
Tobias

We haven’t updated this yet. But thanks for the reminder. I’ll make sure it’s on the docket to take a look at. For now, the work around is to implement tax %’s/etc WP/PMPro side like this. When doing tax stuff, you should always use the actual data coming out of Stripe. Because any tax gets added to the total, you’ll have to “back out” the tax from the totals in Stripe.

So if you sell $100 products add a 20%/$20 tax, it will show up in Stripe as a $120 charge. Then you need to back out the tax amount from the final totals. If you have a 20% tax (multiplying total by 1.2 to get full amount), then you need to divide your totals on Stripe by 1.2.

The formula would look something like:
(tax amount) = (Stripe order total) – (Stripe order total)/(1+tax percent as decimal)

So:
Tax Amount = $120 – ($120/1.2) = $20

Hope this helps.

Hi Jason and Kim,

This code got me started and I’ve successfully used this to programatically set tax amounts (in my case, 20% in the UK and 0% elsewhere). The charge has gone through to Stripe, but unfortunately it’s just altered the total amount rather than used Stripe’s `tax_percent` field ( https://stripe.com/docs/api#create_subscription-tax_percent ).

As far as I can tell, this isn’t the fault of the above plugin, but more that tax amounts simply get wrapped into the total rather than being charged separately – I think it’s here https://github.com/strangerstudios/paid-memberships-pro/blob/dev/classes/gateways/class.pmprogateway_stripe.php#L1374

This is a pretty big issue as without this it makes calculating what amounts have to be remitted to the tax authorities a pretty tedious task.

I’m going to continue playing around with it and see if I can work out how to submit `tax_amount` independently (and if I work something out I’ll submit a PR)… but hope that you can help me with some pointers as I can’t work out (yet) where the subscription is set up (as opposed to the plan).

I’m going to open an issue on GitHub for this as well as I believe it’s more of a general improvement than a specific requirement for me – I can’t see a reason not to use Stripe’s `tax_percent`

All the best,

Andrew

I think the tax_percent wasn’t available when we first integrated with Stripe, but now that I know about it, I’ll see if we can use it in our API calls to make reporting on taxes from Stripe easier. Thanks for the heads up.

Hi Jason,

My apologies! I didn’t see your reply when I wrote mine!

I think you’re right – the official Stripe PHP SDK doesn’t even include tax_percent, so I’m not surprised if it’s a later API feature.

Based on my code it looks like it should be a pretty straightforward addition, though I guess there will need to be some futher logic around the pmpro_tax hook to add tax to the subtotal (if not Stripe) or add an element to the subscription array (if Stripe).

Best of luck!

Cheers,

Andrew

Hi Jason,

if i want to use this addon but whitout the checkbox, how can i do ?
I want to apply french tax (20%) directly for all VIP members of my website. So i don’t want checkbox.
Which lines of your php file do i change to hide checkbox ?

forget my request. it’s ok.

But i’m not very happy, because i need to add a Tax which includes itself into membership price.
I see others comments above mine, and there is no answer for that…

Honestly, I would just include the tax in the membership price and add something to the description RE how much is tax. If you post to the member forums, we can code something up for you to just apply 20% tax to all orders for a specific level if it’s important to you that the tax be separated out as much as possible.

Hello Jason!

I would like to know if this plugin can add the TAX/IVA from Portugal that is 22% automatically on the membership. Example:
Total price of membership 1 is “100 €” (it will only show that on the membership selection) and then on the checkout it will add the TAX of portugal to the total price and the total price will be 122€ (example).

What would I need to change to make the tax be included in the price which is displayed to the customer while on the checkout page?

I’m using a static tax percentage (25 %) for all customers, so there are no text-boxes or need for dynamic updates to the price depending on tax region.

Specific question: I’ve got this working on the site but I need to add multiple options for different regions. Do I need to duplicate a PHP file for each region or can I modify the one PHP file to use a drop-down? Before you ask me to ask in the members forum, I don’t have the $97 to upgrade to that.

Sounds like you could change the checkbox to a dropdown and update the PHP code checking for the checkbox to check the value of the dropdown. If you get something working, share it here.

Hi,

Please help me……………

i am using Paid Memberships Pro and want to apply shipping cost or tax on my subscription plan product (3.99$ for Usa and 4.99 for Canada ) so is there any way to do this thing ???????????????

Hi,

I have installed the plugin and it seems to work however the amount the user pays does not change. They can choose to check the tax box or not and the amount they pay is the same. This is with Paypal Express.

Any suggestions?

Cheers
Adam

Hi Jason,
I am looking for a plugin that actually shows the VAT tax on the total billed, before we get to paypal (that is, before they pay for their membership on the 3rd party site, i.e, paypal).

I have followed the steps above and uploaded and activated this plugin from above, but this plugin ADDS TAX ON TOP of the membership.

Is there a way I could select the tax I want added be INCLUDED in the membership price? AND SHOWING the tax?

I am charging tax on all membership levels, and on all locations, US but mostly outside US, so I need some other options.

I’m really hoping that there is 🙂
THANKS!

Dhyana, I’m not understanding completely. Do you need to have the tax amount itemized in PayPal? Which version of PayPal are you using? Can you be more specific about how you’d like things to show up on the PMPro checkout page, then PayPal, then the confirmation and invoices? Syncing “tax amounts” with PayPal is tough, but we might be able to help you here.

Hi Jason, I think what Dhyana is getting at, is exactly what I need to. All my customers are subscribers to a dating site (buddypress) and therefore none will be businesses and therefore none will be vat registered – i.e. no requirement to ask whether customers is vat registered.

Overall is customers/people who will be registering. As my business is in the UK and I am vat registered, i have to charge vat to my customers. However, to reduce confusion to my customers on signup (they shouldn’t bare the confusion of whether vat is or isnt added and what is the total cost) , i only want my membership prices to be displayed on the website “inclusive” of tax. So £100 total membership cost which is made up of £80 fee and £20 vat.

What i want is for the cost of the membership to be displayed as £100, but on the payment invoice (plugin and/or paypal if possible too) I must show the vat amount paid by the customer to comply with UK law – therefore split out £80 fee and £20 tax again.

Thanks for clarifying that. If one of you posts this to our forums, I can follow up there with some code to do that. You can use the pmpro_tax filter to just add the tax to all orders. The price does not always show up broken down into total + tax, but we can work to do that as much as possible in the customer emails and invoices.

E.g., here is the code to just add the tax to all orders:
`
function customtax_pmpro_tax($tax, $values, $order)
{
$tax = round((float)$values[price] * 0.07, 2);
return $tax;
}
add_filter(“pmpro_tax”, “customtax_pmpro_tax”, 10, 3);
`

In the situation of European VAT it will mean charging to non business and businesses who don’t provide their VAT registrataion number. To non European customers it would be without.
Also, be aware that the European VAT Directive will change per Jan 1st, 2015, meaning we need to be able to charge various VAT percentages, based on where the customer is located.
Does the solution above allows modification to support the current VAT requirements as described in the beginning of my comment?

I imagine this code would have to be updated for your situation. The logic seems pretty straightforward. If you open a thread in our support forums and point us toward the official VAT documentation for your region, we can tweak this script for you.

Hi Smartlady and Jason. Has this tweak for the code been released yet? Now that the deadline for the new EU tax rules has passed, by law we need to implement this on our websites using pmpro. Thanks.

Not yet, but I think we might have something soon. This came up in the forums again. For whatever reason, each time I’m about to dig into this to create a VAT-specific plugin, the person requesting it (if a PMPro member/etc) decides they don’t really need it. I’ll be sure to blog about it once we get it done if we do.

How can I use this plugin not to add vat but to reduce a % from the amount?

Also, how can I change “if(($bstate == “bc” || $bstate == “british columbia”) && $bcountry = “ca”)” an EU country?

Hi!

How can I check if the country selected on buddypress profile is from a specific country so that the checkbox can be automatically selected?

That’s a very specific request about another plugin. The BuddyPress profile fields are stored in usermeta, so you could find the user meta field and check it on the checkout page when setting the field up. You can pass a “value” to a PMProRH field to give it a default value.

Thanks, but my question is related with the one placed by fpierron. I’m totaly lost on how to do this because I need to charge vat on customers from portugal… Can you help?

I think that this support post deserves a bit more courtesy from the author just because there are themes that integrate the plugin spreading him too

Did you put it somewhere into your latest version ?
I need to add VAT for european customers and exclude it for non european customers.
Also if the European customer is a company, if the company give us its European VAT number, the VAT can be excluded from the price.
Is there a way to do that ? It is the rules for the 27 countries of the european market 😉

Leave a Reply

For faster support related to issues on your specific site please open a ticket in our members support area.

Your email address will not be published. Required fields are marked *