Created
April 8, 2025 14:03
-
-
Save dwanjuki/c9ceaa536d5662e58d1a6a0da6736332 to your computer and use it in GitHub Desktop.
Apply 10% tax (GST) if Billing Address is in Australia
This file contains hidden or 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 | |
/** | |
* Apply 10% tax if Billing Address is in Australia | |
* | |
* Requires Billing Address fields on checkout page | |
* | |
* 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. | |
* https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/ | |
*/ | |
function my_pmpro_tax_agst( $tax, $values, $order ) { | |
if ( isset( $values['billing_country'] ) && strtolower( $values['billing_country'] ) == 'au' ) { | |
$tax = round( (float)$values['price'] * 0.1, 2 ); | |
} | |
return $tax; | |
} | |
add_filter( 'pmpro_tax', 'my_pmpro_tax_agst', 10, 3 ); | |
function my_pmpro_level_cost_text_agst( $cost, $level ) { | |
$cost .= ' Customers in Australia will be charged a 10% GST.'; | |
return $cost; | |
} | |
add_filter( 'pmpro_level_cost_text', 'my_pmpro_level_cost_text_agst', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment