Advertisement
Guest User

Untitled

a guest
Jun 19th, 2019
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. add_filter('woocommerce_product_get_price', 'switch_price', 99, 2);
  2. add_filter('woocommerce_product_variation_get_price', 'switch_price', 99, 2);
  3. function switch_price($price, $product){
  4.  
  5. if(isset($_COOKIE["customerType"])){
  6. if($_COOKIE["customerType"] == "business"){
  7. $product->set_tax_class("Zero Rate");
  8. }
  9. }
  10.  
  11. return $price;
  12. }
  13.  
  14. add_filter('woocommerce_product_get_tax_class', 'switch_product_tax_class', 100, 2 );
  15. add_filter('woocommerce_product_variation_get_tax_class', 'switch_product_tax_class', 100, 2 );
  16. function switch_product_tax_class( $tax_class, $product ){
  17. if( isset($_COOKIE["customerType"]) && $_COOKIE["customerType"] == 'business' ){
  18. return "Zero Rate";
  19. }
  20. return $tax_class;
  21. }
  22.  
  23. add_action( 'template_redirect', 'vat_exempt_b2b_customers' );
  24. function vat_exempt_b2b_customers() {
  25. if( isset($_COOKIE["customerType"]) && $_COOKIE["customerType"] === 'business'
  26. && ! WC()->customer->is_vat_exempt() ){
  27. WC()->customer->set_is_vat_exempt( true );
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement