Created
September 20, 2016 08:55
-
-
Save remcotolsma/b895d81ffc21ac7ad55d0b7938b4ac75 to your computer and use it in GitHub Desktop.
Display WooCommerce prices exlcuding tax for distributors.
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 | |
/* | |
Plugin Name: SunStofey WooCommerce Prices Excluding Tax for Distributors | |
Plugin URI: https://www.pronamic.eu/ | |
Description: Display WooCommerce prices exlcuding tax for distributors. | |
Author: Pronamic | |
Version: 1.0.0 | |
Author URI: https://www.pronamic.eu/ | |
*/ | |
/** | |
* Override WooCommerce tax display option for distributors. | |
* | |
* @see http://stackoverflow.com/questions/29649963/displaying-taxes-in-woocommerce-by-user-role | |
* @see https://github.com/woothemes/woocommerce/blob/v2.2.3/includes/admin/settings/class-wc-settings-tax.php#L147-L158 | |
* @see https://github.com/woothemes/woocommerce/blob/v2.2.3/includes/admin/settings/class-wc-settings-tax.php#L166-L178 | |
* @see https://github.com/WordPress/WordPress/blob/4.6.1/wp-includes/option.php#L37-L52 | |
*/ | |
function sunstofey_override_woocommerce_tax_display( $value ) { | |
if ( current_user_can( 'distributor' ) ) { | |
return 'excl'; | |
} | |
return $value; | |
} | |
add_filter( 'pre_option_woocommerce_tax_display_shop', 'sunstofey_override_woocommerce_tax_display' ); | |
add_filter( 'pre_option_woocommerce_tax_display_cart', 'sunstofey_override_woocommerce_tax_display' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment