Hikashop + AkeebaSubs PHP Error

  • Posts: 5
  • Thank you received: 0
11 years 4 months ago #111414

I have a free product that gets added to the cart and then checked out. Everything works great, and the transaction goes through, but I get this warning message.

Warning: Division by zero in /home/content/14/9851214/html/plugins/hikashop/akeebasubs/akeebasubs.php on line 158

I am assuming it is because somewhere the price or total is = 0. Is there anyway I can suppress or fix this warning?

Thanks

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 4 months ago #111441

I suppressed the warning with

@error_reporting(0);
@ini_set('display_errors', 0);

not a real fix, but it will have to do for now :)

Please Log in or Create an account to join the conversation.

  • Posts: 26151
  • Thank you received: 4027
  • MODERATOR
11 years 4 months ago #111443

Hi,

The line that you pointed is:

if(!empty($result->order_product_price)) $taxPercent = round($result->order_product_tax / $result->order_product_price * 100, 2);
Problem is, if you have a free product, it should be see as empty in the if. This test is here to not make a division by zero.

Do you have this same code in your line 158 ?

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 3 months ago #116343

I am having the same error on line 158 and I don't understand what you mean ...

I have products that aren't free by default but have discounts that make them free and for those it works fine without an error. However, when using with Akeeba Subscriptions, I get the error.

thanks!

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 3 months ago #116436

Hi,

Do you have the latest version of HikaShop ? V2.2.0 ?

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 3 months ago #116667

Hi,
Yes, I am running V2.2.0

thanks

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
11 years 3 months ago #116765

Hi,

Line 158 of the akeebasubs plugin, you have to change the line:

					if(!empty($result->order_product_price))
						  $taxPercent = round($result->order_product_tax / $result->order_product_price * 100, 2);
By:
					if(!empty($result->order_product_price) && hikashop_toFloat($result->order_product_price) != 0.0)
						$taxPercent = round($result->order_product_tax / $result->order_product_price * 100, 2);

The following user(s) said Thank You: joji

Please Log in or Create an account to join the conversation.

  • Posts: 5
  • Thank you received: 0
11 years 3 months ago #116866

Thanks, that worked!

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds
Powered by Kunena Forum