title: Display product prices with a shortcode by product ID in WooCommerce
body: <p>IN WooCommerce I am using the code of this <a href="https://stackoverflow.com/questions/38817195/how-to-display-woocommerce-product-price-by-id-with-correct-commas?noredirect=1&amp;lq=1">tread</a> to display with a short code the product prices from a defined product ID. But it don't really do what I want. Here is that code:</p>
  
  <pre><code>function so_30165014_price_shortcode_callback( $atts ) {
  $atts = shortcode_atts( array(
  'id' =&gt; null,
  ), $atts, 'bartag' );
  
  $html = '';
  
  if( intval( $atts['id'] ) &gt; 0 &amp;&amp; function_exists( 'wc_get_product' ) ){
   $_product = wc_get_product( $atts['id'] );
   $number = number_format($_product-&gt;get_price(), 2, '.', ',');
   $html = "$" . $number;
  
   }
   return $html;
   }
   add_shortcode( 'woocommerce_price', 'so_30165014_price_shortcode_callback' );
  </code></pre>
  
  <p>I have a poor knowledge in php coding. But I've seen that there <a href="https://stackoverflow.com/questions/30165014/how-to-display-woocommerce-product-price-by-id-number-on-a-custom-page">this other thread</a> to display product prices:</p>
  
  <pre><code>$_product-&gt;get_regular_price();
  $_product-&gt;get_sale_price();
  $_product-&gt;get_price();
  </code></pre>
  
  <p>I Have tried to mix these code into the big code, and replaced <code>get_price()</code>… It works, but what I want is to display prices is something like this :</p>
  
  <p><a href="https://i.stack.imgur.com/0VtUq.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0VtUq.png" alt="What I want to display"></a></p>
  
  <p>So the Regular price crossed out, and the Sale price next to it, like in this screenshot. If there is no Sale price, it display only the regular price.</p>
  
  <p>Also I have some other problems: </p>
  
  <ul>
  <li><p>I need to display the price is in <code>€</code>, <strong>not in <code>$</code></strong>, so I have replaced the currency symbol from <code>$</code> <em>(dollars)</em> to <code>€</code> <em>(euros)</em> with this code: <code>$html = "€" . $number;</code> </p></li>
  <li><p>I need to display the currency symbol after the price, like : <code>37 €</code> (with a blank space between), not like <code>$37</code>.</p></li>
  </ul>
  
  <p>How can I make it work in a clean normal way?</p>