Forked from strangerstudios/pmpro-australia-gst.php
Last active
July 23, 2018 10:21
-
-
Save andrewlimaza/cb7f86ced97c701a34ebedbc7a81de24 to your computer and use it in GitHub Desktop.
Paid Memberships Pro - Australia GST
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
Plugin Name: Paid Memberships Pro - Australia GST | |
Plugin URI: http://www.paidmembershipspro.com/wp/pmpro-australia-gst/ | |
Description: Apply Australia GST to Checkouts with PMPro | |
Version: .1 | |
Author: Stranger Studios | |
Author URI: http://www.strangerstudios.com | |
*/ | |
/* | |
Tax solution for Australia | |
This solution assume the GST tax rate of 10% from March 15th, 2017. Ask your accountant how much tax you must charge. | |
More info: https://www.business.gov.au/info/run/tax/register-for-goods-and-services-tax-gst | |
Edit as needed, then save this file in your plugins folder and activate it through the plugins page in the WP dashboard. | |
*/ | |
//add tax info to cost text. this is enabled if the danish checkbox is checked. | |
function agst_pmpro_tax($tax, $values, $order) | |
{ | |
$tax = round((float)$values[price] * 0.1, 2); | |
return $tax; | |
} | |
function agst_pmpro_level_cost_text($cost, $level) | |
{ | |
//only applicable for levels > 1 | |
$cost .= __(" Customers in Australia will be charged a 10% tax.", 'pmpro-australia-gst'); | |
return $cost; | |
} | |
add_filter("pmpro_level_cost_text", "agst_pmpro_level_cost_text", 10, 2); | |
//set the default country to Australia | |
function agst_pmpro_default_country($country) { | |
return 'AU'; | |
} | |
add_filter('pmpro_default_country', 'agst_pmpro_default_country'); | |
//update tax calculation if buyer is danish | |
function agst_region_tax_check() { | |
//check state and country | |
if (! empty( $_REQUEST['bcountry'] ) ) { | |
$bcountry = trim(strtolower($_REQUEST['bcountry'])); | |
if($bcountry == "au") { | |
//billing address is in AU | |
add_filter("pmpro_tax", "agst_pmpro_tax", 10, 3); | |
} | |
} | |
} | |
add_action("init", "agst_region_tax_check"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment