How can I show the amount saved in Magento 2?
<p>I am trying to display amount saved on the catalog page for a Magento 2.0.2 website. However I'm not getting the calculation result displayed. I just get an empty space. I am editing the final_price.phtml in my theme file.</p>
<p>I didn't find any information in google as most results are for related to Magento 1 and the codes are throwing errors.</p>
<p>This is what my code looks like in the section which I am trying to do the calculations.</p>
<pre><code>&lt;span class=&quot;special-price&quot;&gt;&lt;span class=&quot;only-text&quot;&gt;Only: &lt;/span&gt;
    &lt;?php echo $block-&gt;renderAmount($finalPriceModel-&gt;getAmount(), [
        'display_label'     =&gt; __('Special Price'),
        'price_id'          =&gt; $block-&gt;getPriceId('product-price-' . $idSuffix),
        'price_type'        =&gt; 'finalPrice',
        'include_container' =&gt; true,
        'schema' =&gt; $schema
    ]); ?&gt;
&lt;/span&gt;
&lt;br&gt;
&lt;span class=&quot;old-price&quot;&gt;&lt;span class=&quot;rrp-text&quot;&gt;RRP: &lt;/span&gt;
    &lt;?php echo $block-&gt;renderAmount($priceModel-&gt;getAmount(), [
        'display_label'     =&gt; __('Regular Price'),
        'price_id'          =&gt; $block-&gt;getPriceId('old-price-' . $idSuffix),
        'price_type'        =&gt; 'oldPrice',
        'include_container' =&gt; true,
        'skip_adjustments'  =&gt; true
    ]); ?&gt;
&lt;/span&gt;
&lt;span class=&quot;saving-price&quot;&gt;&lt;span class=&quot;saving-text&quot;&gt;Saving: &lt;/span&gt;
&lt;?php
$wasPrice = $block-&gt;renderAmount($priceModel-&gt;getAmount(), []);
$nowPrice = $block-&gt;renderAmount($finalPriceModel-&gt;getAmount(), []);
  if ($nowPrice &lt; $wasPrice){
    $saving = $wasPrice - $nowPrice; 
    echo $saving;
  }
?&gt;
&lt;/span&gt;
</code></pre>