{"id":11516990,"date":"2019-05-10T10:49:05","date_gmt":"2019-05-10T10:49:05","guid":{"rendered":"https:\/\/wordpress.org\/support\/topic\/warning-division-by-zero-sale-flash-php-on-line-25\/"},"modified":"2019-05-10T10:49:05","modified_gmt":"2019-05-10T10:49:05","slug":"warning-division-by-zero-sale-flash-php-on-line-25","status":"publish","type":"topic","link":"https:\/\/wordpress.org\/support\/topic\/warning-division-by-zero-sale-flash-php-on-line-25\/","title":{"rendered":"Warning: Division by zero (sale-flash.php on line 25)"},"content":{"rendered":"<p>Today I updated the following plugins and theme in localhost before updating them of my live site.<\/p>\n<p>WooCommerce\u2014&gt; Version 3.6.2<br \/>\nWOOCS \u2013 WooCommerce Currency Switcher\u2014&gt; Version 1.2.8.1<br \/>\nPorto Theme\u2014&gt; Version 4.11.2 (Apr 23.2019)<\/p>\n<p>Now following error message is appeared in variable product page once changed the default currency through WOOCS currency switcher. Please let me how to fix that that error. I am afraid to update my live site without fix this error.<\/p>\n<p>\u201cWarning: Division by zero in C:\\xampp\\htdocs\\mrudukanga.lk\\wp-content\\themes\\porto\\woocommerce\\single-product\\sale-flash.php on line 25\u201d<\/p>\n<p>Screenshots: Product page\u2014&gt; https:\/\/prnt.sc\/nmqa3v<br \/>\nCurrency Settings\u2014&gt; https:\/\/prnt.sc\/nmrmkz<\/p>\n<p>Sale-flash.php Code:<\/p>\n<pre>\n&lt;?php\n\/**\n * Single Product Sale Flash\n *\n * @version     1.6.4\n *\/\n\nif ( ! defined( 'ABSPATH' ) ) {\n    exit;\n}\n\nglobal $post, $product, $porto_settings;\n\n$labels = '';\nif ($porto_settings['product-hot']) {\n    $featured = $product-&gt;is_featured();\n    if ($featured) {\n        $labels .= '&lt;div class=\"onhot\"&gt;'. ((isset($porto_settings['product-hot-label']) &amp;&amp; $porto_settings['product-hot-label']) ? $porto_settings['product-hot-label'] : __('Hot', 'porto')) .'&lt;\/div&gt;';\n    }\n}\n\nif ( $porto_settings['product-sale'] &amp;&amp; $product-&gt;is_on_sale() ) {\n    $percentage = 0;\n    if ($product-&gt;get_regular_price())\n        $percentage = - round( ( ( $product-&gt;get_regular_price() - $product-&gt;get_sale_price() ) \/ $product-&gt;get_regular_price() ) * 100 );\n    if ($porto_settings['product-sale-percent'] &amp;&amp; $percentage)\n        $labels .= '&lt;div class=\"onsale\"&gt;'. $percentage .'%&lt;\/div&gt;';\n    else\n        $labels .= apply_filters( 'woocommerce_sale_flash', '&lt;span class=\"onsale\"&gt;' . ((isset($porto_settings['product-sale-label']) &amp;&amp; $porto_settings['product-sale-label']) ? $porto_settings['product-sale-label'] : __('Sale', 'porto')) . '&lt;\/span&gt;', $post, $product );\n}\necho '&lt;div class=\"labels\"&gt;';\n\necho $labels;\n\necho '&lt;\/div&gt;';\n?&gt;\n<\/pre>\n<p>Thank you<\/p>\n","protected":false},"template":"","class_list":["post-11516990","topic","type-topic","status-publish","hentry"],"jetpack_sharing_enabled":true,"_links":{"self":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11516990","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic"}],"about":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/types\/topic"}],"version-history":[{"count":0,"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/topic\/11516990\/revisions"}],"wp:attachment":[{"href":"https:\/\/wordpress.org\/support\/wp-json\/wp\/v2\/media?parent=11516990"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}