• Resolved Make carlos

    (@make-carlos)


    I want price like this everywhere(archive, product detail etc) :

    £1167.00 (£1400.40 inc. VAT) so have added below functions, which is working fine.
    but if i enable this options: Both ajax search results and search results page
    then All price showing at top of page like this:

    https://prnt.sc/ur0oqf

    Can you please advice.

    function edit_price_display($price, $product) {
      $product = wc_get_product( get_the_ID() );
      $price = $product->price;
     
      $price_incl_tax = $price + round($price * ( 20/ 100 ), 2);
      $price_incl_tax = number_format($price_incl_tax, 2, ".", ","); 
      $price = number_format($price, 2, ".", ","); 
     
      $display_price = '<span class="price custom-price">';
      $display_price .= '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>'.$price. '</span> <small class="woocommerce-price-suffix">(<span class="woocommerce-Price-amount amount">
    <span class="woocommerce-Price-currencySymbol">£</span>'.$price_incl_tax .'</span> inc. VAT)</small>';
      $display_price .= '</span>';
      echo $display_price;
      
    } 
    add_filter('woocommerce_price_html', 'edit_price_display');
    add_filter('woocommerce_variable_price_html', 'edit_price_display', 10, 2);
Viewing 1 replies (of 1 total)
  • Plugin Author ILLID

    (@mihail-barinov)

    Hi,

    I see that your code is not valid. Please use this instead

    function edit_price_display($price, $product) {
        $price = $product->get_price();
        $price_incl_tax = $price + round($price * ( 20/ 100 ), 2);
        $price_incl_tax = number_format($price_incl_tax, 2, ".", ",");
        $price = number_format($price, 2, ".", ",");
        $display_price = '<span class="price custom-price">';
        $display_price .= '<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">£</span>'.$price. '</span> <small class="woocommerce-price-suffix">(<span class="woocommerce-Price-amount amount">
    <span class="woocommerce-Price-currencySymbol">£</span>'.$price_incl_tax .'</span> inc. VAT)</small>';
        $display_price .= '</span>';
        return $display_price;
    
    }
    add_filter('woocommerce_price_html', 'edit_price_display', 10, 2);
    add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);
    add_filter('woocommerce_variable_price_html', 'edit_price_display', 10, 2);
Viewing 1 replies (of 1 total)
  • The topic ‘Search result with including tax not working’ is closed to new replies.