How can I not have Warning: Division by zero in
if I choose even to put zero. I want to have the option to leave the price empty, but if I leave empty, it multiplies as it is in the discount formula and gives error. You can not show this div
if deal_price
and deal_sale_price
are empty or 0?
<ul class="deal-single-value">
<?php
$deal_price = get_post_meta( get_the_ID(), 'deal_price', true);
$deal_sale_price = get_post_meta( get_the_ID(), 'deal_sale_price', true);
?>
<li>
<p><?php esc_html_e( 'Preço Antigo', 'site' ) ?></p>
<?php echo site_format_price_number( $deal_price ) ?>
</li>
<li>
<p><?php esc_html_e( 'Desconto de', 'site' ) ?></p>
<?php echo round( 100 - ( $deal_sale_price / $deal_price ) * 100 ).'%'; ?>
</li>
<li>
<p><?php esc_html_e( 'Você economizou', 'site' ) ?></p>
<?php echo format_price_number( $deal_price - $deal_sale_price ) ?>
</li>
</ul>