Forked from webdados/woocommerce_show_prices_with_or_without_tax.php
Created
October 11, 2019 06:17
-
-
Save ashokmhrj/e1ff93c17946f38eb078a11b4dec0265 to your computer and use it in GitHub Desktop.
Show WooCommerce prices with or without tax / VAT depending on user profile / option
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 | |
/* WooCommerce prices shown with or without tax depending on client type */ | |
add_filter( 'option_woocommerce_tax_display_shop', 'woocommerce_show_prices_with_or_without_tax' ); | |
add_filter( 'option_woocommerce_tax_display_cart', 'woocommerce_show_prices_with_or_without_tax' ); | |
function woocommerce_show_prices_with_or_without_tax( $option ) { | |
if ( is_user_logged_in() ) { | |
//Client type from user_meta or profile or whatever... | |
//Example: $client_hide_tax = get_user_meta( get_current_user_id(), 'client_type', true ) ? true : false; | |
//Example to create this field on registration: https://gist.github.com/webdados/c8dbbe7ccdea3463312e5b865ad92d92 | |
$client_hide_tax = true; | |
return $client_hide_tax ? 'excl' : $option; | |
} else { | |
/* Assumes "Display prices in the shop" and "Display prices during cart and checkout" is set to "Including tax" in WooCommerce > Settings > Tax */ | |
return $option; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment