• Resolved Amoditer

    (@amoditer)


    Hello,

    I like your plugin, and use on many site, great plugin, thank you for your work.

    I have a problem:
    My client want to show on his woocommerce site the price with include and exclude tax.

    I use this function for that, and it works great, woocommerce show both price, but is kill your plugin suggest part, it makes 500 error in it.

    Please help me, what I need to modify to works well with your plugin, thank you.

    This is the code:

    function edit_price_display() {
      $product = new WC_Product( get_the_ID() );
      $price = $product->price;
     
      $price_incl_tax = $price + round($price * ( 27 / 100 ), 2);
     
      $price_incl_tax = number_format($price_incl_tax, 0, ",", "."); 
      $price = number_format($price, 0, ",", "."); 
     
      $display_price = '<span class="price">';
        $display_price .= '<span class="amount"><small class="woocommerce-price-suffix"> without tax: </small>' . $price .' Ft</span></br>';
      $display_price .= '<span class="amount"><small class="woocommerce-price-suffix"> with tax: </small>' . $price_incl_tax .' Ft</span>';
      $display_price .= '<br>';
      $display_price .= '</span>';
     
      echo $display_price;
    }
     
    add_filter('woocommerce_get_price_html', 'edit_price_display');
    • This topic was modified 8 years, 1 month ago by Amoditer.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author YummyWP

    (@yummy-wp)

    Hello,

    yeah, that code is not working

    try this :

    
    function edit_price_display( $price, $product ) {
    	$price = $product->price;
    	$price_incl_tax = $price + round($price * ( 27 / 100 ), 2);
    
    	$price_incl_tax = number_format($price_incl_tax, 0, ",", ".");
    	$price = number_format($price, 0, ",", ".");
    
    	$display_price = '<span class="price">';
    	$display_price .= '<span class="amount"><small class="woocommerce-price-suffix"> without tax: </small>' . $price .' Ft</span></br>';
    	$display_price .= '<span class="amount"><small class="woocommerce-price-suffix"> with tax: </small>' . $price_incl_tax .' Ft</span>';
    	$display_price .= '<br>';
    	$display_price .= '</span>';
    
    	return $display_price;
    }
    
    add_filter('woocommerce_get_price_html', 'edit_price_display', 10, 2);
    

    Best
    Stanislav

    Plugin Author YummyWP

    (@yummy-wp)

    Set resolved due to inactivity.

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Price problem’ is closed to new replies.