cart items error - not updating

  • Posts: 76
  • Thank you received: 4
  • Hikashop Business
6 years 4 months ago #294783

-- url of the page with the problem -- : betascreens.com/index.php
-- HikaShop version -- : 3.4.1
-- Joomla version -- : 3.8.10
-- PHP version -- : 7.0.30
-- Browser(s) name and version -- : firefox
-- Error-message(debug-mod must be tuned on) -- : Warning: Missing argument 1 for hikashopCartClass::get(), called in /home/wetroomi/public_html/betascreens.com/tests/cart_items.php on line 7 and defined in /home/wetroomi/public_html/betascreens.com/administrator/components/com_hikashop/classes/cart.php on line 79

Notice: Undefined variable: element in /home/wetroomi/public_html/betascreens.com/administrator/components/com_hikashop/classes/cart.php on line 87

Notice: Undefined property: stdClass::$cart_product_option_parent_id in /home/wetroomi/public_html/betascreens.com/tests/cart_items.php on line 11

Notice: Undefined property: stdClass::$cart_product_quantity in /home/wetroomi/public_html/betascreens.com/tests/cart_items.php on line 12

Notice: Trying to get property of non-object in /home/wetroomi/public_html/betascreens.com/tests/cart_items.php on line 11

Hi,

I have recently taken over two sites, and subsequently updated to the latest versions of Joomla and Hikashop Business.

Both sites are using a Gantry template.

Both sites appear to have a custom solution to displaying the number of items added to the cart.

I did the Joomla update two days ago and the cart items update were still working, however following the update of Hikashop the cart items are no longer updating.

The error I have posted in this post is the same on both sites. (I have now switched error reporting off)

I have followed the error and there is a file called "cart_items.php" in a "tests" folder within the root folder.

Here is the code in the cart_items.php file:

<span style="font-family: courier new, courier, monospace;">
<?php
require_once('/home/wetroomi/public_html/diywetroom.com/administrator/components/com_hikashop/helpers/helper.php'); 
$class = hikashop_get('class.cart');
$rows = $class->get();
$qty = 0;
if(!empty($rows)){
foreach($rows as $k =>$row){
if($row->cart_product_option_parent_id) continue;
$qty += $row->cart_product_quantity;
}
} 
echo $qty; 
?>
</span>

And in the Gantry template of there is the following code:
<div id="mobile-logo">
<div class="mobile-logo-content">
<a href="/index.php"><img src="images/logo.png"></a>
</div>
</div>
<div id="cart">
<div class="items">
{source file=tests/cart_items.php}{/source}
<!--Shopping CART link -->
</div>
<div class="cart-content">
<a href="/checkout"><img src="images/icons/cart.png"></a>
</div>
</div>

I have tried turning off the cart legacy options, but this didn't seem to make any difference - I guess because this is a custom solution.

I'm not really a coder, so my knowledge is not good enough to work out how to fix this specific problem.

I would be so grateful if you anyone can help me in working out how to fix the issue, everything else appears to be working fine.

Many thanks in advance

Duncan


DunxMax

The more we learn the less we know.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 4 months ago #294802

Hi,

I would recommend to try changing the code of the cart_items.php file to that:

<span style="font-family: courier new, courier, monospace;">
<?php
require_once('/home/wetroomi/public_html/diywetroom.com/administrator/components/com_hikashop/helpers/helper.php'); 
$class = hikashop_get('class.cart');
$cart = $class->getFullCart();
$qty = 0;
if(!empty($cart->products)){
foreach($cart->products as $k =>$row){
if(!empty($row->cart_product_option_parent_id)) continue;
if(substr($k,0,1) === 'p') continue;
$qty += $row->cart_product_quantity;
}
} 
echo $qty; 
?>
</span>
That will remove the errors.
However, to have the number update dynamically when a product is added to the cart, that will require adding some javascript.
I guess that the simplest would be to refresh the whole page when that happens with such extra code:
<script type="text/javascript">
window.Oby.registerAjax(["cart.updated","checkout.cart.updated"], function(params) {
	window.location.reload();
});
</script>

Last edit: 6 years 4 months ago by nicolas.

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

  • Posts: 76
  • Thank you received: 4
  • Hikashop Business
6 years 4 months ago #294812

Thankyou so much, Nicolas.

I'll give it a go and get back to you.

Duncan


DunxMax

The more we learn the less we know.

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

  • Posts: 76
  • Thank you received: 4
  • Hikashop Business
6 years 4 months ago #294824

Hi Nicolas,

I tried adding the code but it just gave me a blank white screen when I refreshed the home page.

Any ideas as to what might cause that?

Regards

Duncan


DunxMax

The more we learn the less we know.

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

  • Posts: 76
  • Thank you received: 4
  • Hikashop Business
6 years 4 months ago #294832

Hi,

As a further update to my message earlier - I realised Joomla error messages were turned off. So I switched it on and put the code back in.

This is the message it gives:

Fatal error: Cannot declare class hikashop, because the name is already in use in /home/wetroomi/public_html/diywetroom.com/administrator/components/com_hikashop/helpers/helper.php on line 29

I'm afraid I'm still not quite sure what that means exactly.

Line 29 code is this:

jimport('joomla.application.component.controller');

If you can help me resolve this I will be very grateful.

Regards

Duncan


DunxMax

The more we learn the less we know.

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

  • Posts: 82867
  • Thank you received: 13374
  • MODERATOR
6 years 4 months ago #294862

Hi,

It means that the helper.php file that you're requiring is already loaded.
However, with a require_once, it shouldn't create that error. It would if you were using "require" instead of "require_once".
Anyways, you can circumvent the problem by adding:
if(!class_exists('hikashop'))
before the line:
require_once('/home/wetroomi/public_html/diywetroom.com/administrator/components/com_hikashop/helpers/helper.php');

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

Time to create page: 0.068 seconds
Powered by Kunena Forum