Skip to content

Instantly share code, notes, and snippets.

@andrewlimaza
Created July 22, 2021 08:45
Show Gist options
  • Save andrewlimaza/cd0e985634314842690b496fe85769c8 to your computer and use it in GitHub Desktop.
Save andrewlimaza/cd0e985634314842690b496fe85769c8 to your computer and use it in GitHub Desktop.
Add Canadian Tax to PMPro checkout
<?php
/**
* Add 13% tax to all Canadian customers checking out for a membership level.
* To add this code to your site, please follow this guide - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
*/
function customtax_pmpro_tax_ca($tax, $values, $order) {
if ( $_SESSION['bcountry'] == 'CA' || $_REQUEST['bcountry'] == 'CA' ) {
$tax = round( (float) $values[price] * 0.13, 2 );
}
return $tax;
}
add_filter( 'pmpro_tax', 'customtax_pmpro_tax_ca', 10, 3 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment