Created
January 13, 2018 01:40
-
-
Save mtruitt/3a59a89ed33886924a80581a4879b275 to your computer and use it in GitHub Desktop.
Apply fee based on user role
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 | |
function woo_add_cart_fee() { | |
global $woocommerce; | |
$current_user = wp_get_current_user(); | |
if ( in_array( 'residential', $current_user->roles, true) ) { | |
$woocommerce->cart->add_fee( __( 'Custom', 'woocommerce' ), 5 ); | |
} | |
} | |
add_action( 'woocommerce_cart_calculate_fees', 'woo_add_cart_fee' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment