מחיר לפני ואחרי מע"מ ווקומרס

לאחרונה עבדתי על פרוייקט בו הייתי צריך להטמיע מחיר של יחידה + מחיר לפני מע"מ ומחיר כולל מע"מ.

/* PRODUCT CATEGORY PAGE */
remove_action( 'woocommerce_after_shop_loop_item_title','woocommerce_template_loop_price', 10);
/* PRODUCT PAGE */
remove_action( 'woocommerce_single_product_summary','woocommerce_template_single_price', 10, 0);
//add_action( 'woocommerce_single_variation','woocommerce_template_loop_price',10);
//add_action( 'woocommerce_before_add_to_cart_quantity','woocommerce_template_loop_price',10);

// add and display tax to price 
function edit_price_display() {
  $product = new WC_Product( get_the_ID() );
  $price = $product->price;
 
  $price_incl_tax = $price + round($price * ( 17 / 100 ), 2);
 
  $price_incl_tax = number_format($price_incl_tax, 2, ".", "."); 
  $price = number_format($price, 2, ".", "."); 
 
  $display_price = '<span class="price">';
  $display_price .= '<div class="unit-price"><span><small class="woocommerce-price-suffix"> מחיר יח\' ללא מע"מ </small></span>₪<span id="unit-price">'. $price .'</span></div>';
  $display_price .= '<div class="sum-no-tax"><span><small class="woocommerce-price-suffix"> מחיר סה"כ ללא מע"מ </small></span>₪<span id="sum-no-tax">'. $price .'</span></div>';
  $display_price .= '<div class="sum-with-tax"><span><small class="woocommerce-price-suffix"> מחיר סה"כ כולל מע"מ </small><br></span><span id="sum-with-tax" style="font-size:30px;">₪'. $price_incl_tax .'</span></div>';
  $display_price .= '</span>';
 
  echo $display_price;
}
add_action('woocommerce_after_shop_loop_item_title', 'edit_price_display');
add_action('woocommerce_before_add_to_cart_quantity', 'edit_price_display');
jQuery('select,.input-text.qty.text').on('change click', function(e) {
                    // delay function to catch the price
                    setTimeout(function(){  
                        var quantity = jQuery('.input-text.qty.text').val();
                        if(jQuery('.woocommerce-variation-price').children().length == 0 ){
                           var price = jQuery('#unit-price').text();  
                           var newprice = price;    
                           console.log('test1');
                        }
                        else{
                           var price = jQuery('.woocommerce-variation-price').children('.price').children('.woocommerce-Price-amount.amount').text(); 
			   var splitCurrency = price.split("₪",2);
                           var changeTypeToNumber = parseFloat(splitCurrency[1]);
                           var newprice = changeTypeToNumber.toFixed(2);
                           console.log('test2');
                        }
                
			var sumNoTax = newprice * quantity;
			var amountNoTax = sumNoTax.toFixed(2);
			var sumWithTax = newprice * quantity * 1.17;
			var amountTax = sumWithTax.toFixed(2);			
			
			if(price <= 0){}
			else{   
                            jQuery('#unit-price').html(newprice); 
                            console.log(newprice);
                        }
			
			if(price <= 0){}
			else{
				if(quantity <= 1){
                                        jQuery('.sum-no-tax').fadeOut();
				}
                                else{
					jQuery('.sum-no-tax').fadeIn();
					jQuery('#sum-no-tax').html(amountNoTax);
                                        //console.log('test2');
				}
			}
			if(price <= 0){}
			else{jQuery('#sum-with-tax').html('₪'+amountTax);}
                        }, 2000);
		});