php - Apply different tax rate based on user role -
i use woocommerce , members plugin. have created special tax rate classes (customertaxexempttaxclass & customerpstexempttaxclass customers can tax exempt or pay tax (pay pst tax in canada). have created 2 new roles members plugin: customer tax exempt & customer pst exempt.
i have added following code child theme functions.php file, not work.
/* apply different tax rate based on customer user role */ /* special tax rate: 0 if role: customer tax exempt */ function customertaxexempttaxclass( $tax_class, $product ) { global $current_user; if (is_user_logged_in() && current_user_can('customer_tax_exempt')) { $tax_class = 'customertaxexemptclass'; } return $tax_class; } add_filter( 'woocommerce_product_tax_class', 'customertaxexempttaxclass', 1, 2 ); /* special tax rate: charge gst if role: customer_pst_exempt */ function customerpstexempttaxclass( $tax_class, $product ) { global $current_user; if (is_user_logged_in() && current_user_can('customer_pst_exempt')) { $tax_class = 'customerpstexemptclass'; } return $tax_class; } add_filter( 'woocommerce_product_tax_class', 'customerpstexempttaxclass', 1, 2 );
i used suggested tax exempt code snippet, i'm not php expert means.
any appreciated.
thanks lyse
Comments
Post a Comment