• Resolved pocketmo

    (@pocketmo)


    Hi,

    I’ve just installed your plugin and activated it. Please see the error messages being generated on the page. The code referred to in the child theme is below and is to do with price display:

    function edit_price_display() {
      $product = new WC_Product( get_the_ID() );
      $price = $product->price;
     
      $price_incl_tax = $price + round($price * ( 23 / 100 ), 2);
     
      $price_incl_tax = number_format($price_incl_tax, 2, ".", "."); 
      $price = number_format($price, 2, ".", "."); 
     
      $display_price = '<span class="price">';
      $display_price .= '<span class="amount">€ ' . $price .'<small class="woocommerce-price-suffix"></small></span>';
      //$display_price .= '<br>';
      $display_price .= '<span class="taxamount"> (€' . $price_incl_tax .'<small class="woocommerce-price-suffix"> inc. VAT</small>)</span>';
      $display_price .= '</span>';
     
      echo $display_price;
    }
     
    add_filter('woocommerce_price_html', 'edit_price_display');
    add_filter('woocommerce_variable_price_html', 'edit_price_display');
    

    The page I need help with: [log in to see the link]

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author pimwick

    (@pimwick)

    The code in your functions.php isn’t accounting for Variable products. Try this code instead:

    function edit_price_display() {
      $product = new WC_Product( get_the_ID() );
      $price = $product->price;
     
      if ( !empty( $price ) ) {
        $price_incl_tax = $price + round($price * ( 23 / 100 ), 2);
       
        $price_incl_tax = number_format($price_incl_tax, 2, ".", "."); 
        $price = number_format($price, 2, ".", "."); 
       
        $display_price = '<span class="price">';
        $display_price .= '<span class="amount">€ ' . $price .'<small class="woocommerce-price-suffix"></small></span>';
        //$display_price .= '<br>';
        $display_price .= '<span class="taxamount"> (€' . $price_incl_tax .'<small class="woocommerce-price-suffix"> inc. VAT</small>)</span>';
        $display_price .= '</span>';
       
        echo $display_price;
      }
    }
     
    add_filter('woocommerce_price_html', 'edit_price_display');
    add_filter('woocommerce_variable_price_html', 'edit_price_display');
    Thread Starter pocketmo

    (@pocketmo)

    Wow – what a star -super quick response and an improvement on all my product listings. Your code resolved it. Thank you!

    Plugin Author pimwick

    (@pimwick)

    Great, glad to hear that took care of it for you! We would love to have a review of the plugin if you have a minute. Let me know if there is anything else you need!

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Warning message on product listing under price’ is closed to new replies.