Last active
June 28, 2017 22:28
-
-
Save cj-andrew/722d69208f23f054506cd9332fdd4e43 to your computer and use it in GitHub Desktop.
This snippet checks to see if a WooCommerce product is a member of a specific category, upon which a unique Tax class is conditionally applied
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
/** | |
* CJWS: WC Conditional Tax Class | |
* | |
* Provides conditional *tax classes* based on product category | |
* May be adapted to consider other criteria, such as post type | |
* Modifies 'woocommerce_product_tax_class' filter | |
* | |
*@author CJ Andrew <[email protected]> | |
* | |
*@since 1.0 | |
* | |
*@param mixed $tax_class | |
*@param mixed $product | |
* | |
*/ | |
function cjws_wc_conditional_sales_tax($tax_class, $product){ | |
if( is_checkout() && is_product_category('tickets')){ | |
$tax_class = 'Special Rate'; | |
} | |
return $tax_class; | |
} | |
add_filter('woocommerce_product_tax_class', 'wc_diff_rate_for_user', 1,2); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment