title: Extracting from formatted price the number for calculations in WooCommerce
body: <p>I'm working on a custom invoice template with the plugin <a href="https://wordpress.org/plugins/woocommerce-pdf-invoices-packing-slips/" rel="nofollow noreferrer">WooCommerce PDF Invoices &amp; Packing Slips</a> by Ewout Fernhout, and I faced with problem, when I want to create a more detailed product list on the invoice. </p>
  
  <p>There is a foreach loop in the default template which shows all the products from the order:</p>
  
  <pre><code>$items = $this-&gt;get_order_items(); 
  
  if( sizeof( $items ) &gt; 0 ) : 
  
  foreach( $items as $item_id =&gt; $item ) :
  </code></pre>
  
  <p>After that, I'd like to calculate the amount of discount in € and in % based on the <code>$items</code>. I dumped the content, and found that the product price is in <code>$item['price'] (string(119)</code>) and the original price is in the <code>$item['product']-&gt;price (string(3))</code>. I can echo the value of <code>$item['price']</code>, but when I want to get only the price from <code>$item['price']</code> (for example from 250.00€) with substring, but it is useless, returns with nothing or the length value of the function. (With the second variable - <code>$item['product']-&gt;price</code>, I don't have issues)…</p>
  
  <pre><code>$price = $item['price'];
  echo $price.'&lt;br/&gt;';
  echo strlen($price).'&lt;br/&gt;';
  echo substr($price,0,10).'&lt;br/&gt;';
  echo strlen(trim(substr($price,0,10))).'&lt;br/&gt;';
  </code></pre>
  
  <p>It displays:</p>
  
  <blockquote>
    <p>250.00€<br>
    119<br>
    10</p>
  </blockquote>
  
  <p>(It doesn't matter if I write 10 or 2 in the substring, the first occurrence of the substring will return with the length value). I've tried with reference but it neither works…</p>
  
  <p>What can be the root cause?</p>
  
  <p>Thanks</p>