[Skip to main content](#vessel-content)

#   Updating to J 4.2.1 then adding something to cart gives division by zero

##

- **[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")**
- [![nico.van.leeuwen's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile") Topic Author
- [ Offline](/forum/user/12404-nico-van-leeuwen)

Less More

- Posts: 347
- Thank you received: 28
-
-
- [](http://www.delinie-ict.nl)
-

4 years 3 months ago -  4 years 2 months ago [\#344289](#344289) by [nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")  *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344289 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")* was created by *[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")*

-- HikaShop version -- : 4.6.1
-- Joomla version -- : 4.2.1
-- PHP version -- : 8.0

After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is "Division by zero"
The same goes for clicking the cart menu-item.

Any thoughts ?

Last edit: 4 years 2 months ago by [nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile"). Reason: solved

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14327
-
-

4 years 2 months ago [\#344302](#344302) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344302 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi,

I also updated to the 4.2.1 and used the latest build of HikaShop 4.6.1 but I didn't get the error when trying to reproduce.
Could you please activate the "debug system" setting of the Joomla configuration and try again ? Then, please provide the full error message's screenshot.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")**
- [![nico.van.leeuwen's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile") Topic Author
- [ Offline](/forum/user/12404-nico-van-leeuwen)

Less More

- Posts: 347
- Thank you received: 28
-
-
- [](http://www.delinie-ict.nl)
-

4 years 2 months ago [\#344333](#344333) by [nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")  Replied by *[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344333 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi Nicolas,

I've turned every logging on and can see this in the logs :

2022-09-01T18:38:34+00:00 CRITICAL 77.63.33.55 error Uncaught Throwable of type DivisionByZeroError thrown with message "Division by zero". Stack trace: #0 [ROOT]/administrator/components/com_hikashop/helpers/shippingplugin.php(69): hikashopCurrencyClass-&gt;convertUniquePrice()
\#1 [ROOT]/libraries/src/Plugin/CMSPlugin.php(279): hikashopShippingPlugin-&gt;onShippingDisplay()
\#2 [ROOT]/libraries/vendor/joomla/event/src/Dispatcher.php(486): Joomla\CMS\Plugin\CMSPlugin-&gt;Joomla\CMS\Plugin\{closure}()
\#3 [ROOT]/libraries/src/Application/EventAware.php(107): Joomla\Event\Dispatcher-&gt;dispatch()
\#4 [ROOT]/administrator/components/com_hikashop/classes/shipping.php(434): Joomla\CMS\Application\WebApplication-&gt;triggerEvent()
\#5 [ROOT]/administrator/components/com_hikashop/classes/cart.php(1345): hikashopShippingClass-&gt;getShippings()
\#6 [ROOT]/components/com_hikashop/controllers/product.php(548): hikashopCartClass-&gt;getFullCart()
\#7 [ROOT]/libraries/src/MVC/Controller/BaseController.php(672): productController-&gt;updatecart()
\#8 [ROOT]/administrator/components/com_hikashop/helpers/helper.php(2382): Joomla\CMS\MVC\Controller\BaseController-&gt;execute()
\#9 [ROOT]/components/com_hikashop/hikashop.php(88): hikashopController-&gt;execute()
\#10 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(71): require_once('/home/swanndev/...')
\#11 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(73): Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}()
\#12 [ROOT]/libraries/src/Component/ComponentHelper.php(355): Joomla\CMS\Dispatcher\LegacyComponentDispatcher-&gt;dispatch()
\#13 [ROOT]/libraries/src/Application/SiteApplication.php(200): Joomla\CMS\Component\ComponentHelper::renderComponent()
\#14 [ROOT]/libraries/src/Application/SiteApplication.php(241): Joomla\CMS\Application\SiteApplication-&gt;dispatch()
\#15 [ROOT]/libraries/src/Application/CMSApplication.php(294): Joomla\CMS\Application\SiteApplication-&gt;doExecute()
\#16 [ROOT]/includes/app.php(61): Joomla\CMS\Application\CMSApplication-&gt;execute()
\#17 [ROOT]/index.php(32): require_once('/home/swanndev/...')
\#18 {main}

And what I see it something that could be related to shipping?

I hope this is useful.

- [ ![Screenshot2022-09-01at20-44-350-Divisionbyzero.png](/forum/attachment/55461) ](/forum/attachment/55461 "...sionbyzero.png") [ ](/forum/attachment/55461?download=1 "...sionbyzero.png")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14327
-
-

4 years 2 months ago [\#344334](#344334) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344334 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi,

The issue comes from the fact you've updated PHP to 8 and you have a currency with a rate of 0 with a currency setup requiring a price to be converted between two currencies with one with that rate set to 0, which is not possible. A currency rate should normally never be 0 since that would mean it is not possible to convert.
So while we need to modify the code so that even if someone put 0 in a rate, it doesn't crash, the error you have is not really a problem as that's not something that should happen. Just set a rate in your currencies and the error won't happen.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")**
- [![nico.van.leeuwen's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile") Topic Author
- [ Offline](/forum/user/12404-nico-van-leeuwen)

Less More

- Posts: 347
- Thank you received: 28
-
-
- [](http://www.delinie-ict.nl)
-

4 years 2 months ago [\#344365](#344365) by [nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")  Replied by *[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344365 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi Nicolas,

I just checked the currencies but did not find any with a rate of zero.
After updating the rates I still cannot add anything to the cart resulting in the same error.
Just to be certain I sorted the rates to see if I was not mistaken, no currency goes to 0.

Also I was running PHP 8 since starting this site buildt so it does not look like this has any part in this issue.

No problem if you want to take a quick look, I can create an Super User for temp access.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nicolas](/forum/user/63-nicolas "View nicolas's Profile")**
- [![nicolas's Avatar](https://www.hikashop.com/media/kunena/avatars/resized/size144/users/avatar63.png?1793428657)](/forum/user/63-nicolas "View nicolas's Profile")
- [ Offline](/forum/user/63-nicolas)

Less More

- Posts: 86587
- Thank you received: 14327
-
-

4 years 2 months ago [\#344400](#344400) by [nicolas](/forum/user/63-nicolas "View nicolas's Profile")  Replied by *[nicolas](/forum/user/63-nicolas "View nicolas's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344400 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi,

It's strange then.
Change the line: Code:

$price = floatval($price) / floatval($srcCurrency-&gt;currency_rate);

to: Code:

if(!empty($srcCurrency-&gt;currency_rate) &amp;&amp; $srcCurrency-&gt;currency_rate &gt; 0.0) { $price = floatval($price) / floatval($srcCurrency-&gt;currency_rate); }

in the file administrator/components/com_hikashop/classes/currency.php
That's the fix I've made for the error and which will be in the next version of HikaShop.
It should be effective.

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

- **[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")**
- [![nico.van.leeuwen's Avatar](https://www.hikashop.com/media/kunena/core/svg/person.svg)](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile") Topic Author
- [ Offline](/forum/user/12404-nico-van-leeuwen)

Less More

- Posts: 347
- Thank you received: 28
-
-
- [](http://www.delinie-ict.nl)
-

4 years 2 months ago [\#344461](#344461) by [nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")  Replied by *[nico.van.leeuwen](/forum/user/12404-nico-van-leeuwen "View nico.van.leeuwen's Profile")* on topic *[Updating to J 4.2.1 then adding something to cart gives division by zero](/forum/27-checkout/904944-updating-to-j-4-2-1-then-adding-something-to-cart-gives-division-by-zero#344461 "-- HikaShop version -- : 4.6.1 -- Joomla version -- : 4.2.1 -- PHP version -- : 8.0  After I updated my dev site to Joomla 4.2.1 and updated to the latest HikaShop yesterday I noticed that adding anything to the cart is not working anymore. In the console I see that the answer is &quot;Division by zero&quot; The same goes for clicking the cart menu-item.  Any thoughts ?")*

Hi Nicolas,

Thanks, that did the trick.

Nico

The following user(s) said Thank You: [nicolas](/forum/user/63-nicolas "View nicolas's Profile")

Please [Log in](/login?return=aHR0cHM6Ly93d3cuaGlrYXNob3AuY29tL2ZvcnVtLzI3LWNoZWNrb3V0LzkwNDk0NC11cGRhdGluZy10by1qLTQtMi0xLXRoZW4tYWRkaW5nLXNvbWV0aGluZy10by1jYXJ0LWdpdmVzLWRpdmlzaW9uLWJ5LXplcm8/dG1wbD1tYXJrZG93bg==) or [Create an account](/component/users/registration?Itemid=101) to join the conversation.

Board Categories HikaShop Install &amp; Update Product &amp; Category Display Content Creation Sales and Orders Orders management Reports &amp; Statistics Customers Checkout Payment Methods Shipping Methods Import &amp; Export (CSV, XLS…) Specific Features Affilation Taxes Wishlist Vote Carousel &amp; Slider Mass Actions Filters &amp; Search Discount &amp; Coupon Feature Request Integrations Showcase General Talk about HikaShop Development HikaShop 3.0 Beta Translation Commercial Jobs HikaShop Components HikaMarket Market: Feature requests Market: How to? Market: Bug Report HikaSerial General talk about HikaSerial Serial: Bug Report Serial: How to? Support en Français de HikaSerial (French Support) HikaSubscription HikaAuction Auction: Feature requests Auction: How to? Auction: Bug report Hikashop around the world Support en Français (French Support) Russian FAQ. Курс выживания с Hikashop. Частые вопросы и о Расширения Hikashop Наши сайты на Hikashop 日本語版サポート(Japanese Support) Thai German Archives Bug Report How to?

[](/forum/topics/feed/mode-topics?format=feed&type=rss)

Time to create page: 0.075 seconds

[Powered by](/forum/credits) [Kunena Forum](https://www.kunena.org)
