Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- add_filter('woocommerce_product_get_price', 'switch_price', 99, 2);
- add_filter('woocommerce_product_variation_get_price', 'switch_price', 99, 2);
- function switch_price($price, $product){
- if(isset($_COOKIE["customerType"])){
- if($_COOKIE["customerType"] == "business"){
- $product->set_tax_class("Zero Rate");
- }
- }
- return $price;
- }
- add_filter('woocommerce_product_get_tax_class', 'switch_product_tax_class', 100, 2 );
- add_filter('woocommerce_product_variation_get_tax_class', 'switch_product_tax_class', 100, 2 );
- function switch_product_tax_class( $tax_class, $product ){
- if( isset($_COOKIE["customerType"]) && $_COOKIE["customerType"] == 'business' ){
- return "Zero Rate";
- }
- return $tax_class;
- }
- add_action( 'template_redirect', 'vat_exempt_b2b_customers' );
- function vat_exempt_b2b_customers() {
- if( isset($_COOKIE["customerType"]) && $_COOKIE["customerType"] === 'business'
- && ! WC()->customer->is_vat_exempt() ){
- WC()->customer->set_is_vat_exempt( true );
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement