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.
Note that if you’re currently using Stripe Checkout, you won’t need this code recipe. Stripe Checkout seamlessly integrates with Stripe Tax to calculate sales tax, VAT, and GST during the payment step. This makes the process of filing and remitting taxes much simpler for business owners.
Overview of Custom Tax Functionality
- Add a checkbox at checkout for users to self identify themselves from a certain region.
- Add an extra check at checkout to apply tax if the billing address is from a certain country and/or region.
- If the checkbox or the address check matches, apply a certain tax rate at checkout.
- 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
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.