Livechat Errors(Php Notice: Undefined Index: Total In)

hello,

I just install the livechat,but there is an error in my server logs:

[07-Mar-2022 23:50:22 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:23 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:23 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:26 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:27 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:28 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:28 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:28 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:28 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
[07-Mar-2022 23:50:29 Asia/Shanghai] PHP Notice: Undefined index: total in /home/xxxxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 12
Can anyone help.
the livechat.php below:
<?php
use Tygh\Registry;
if (!defined('BOOTSTRAP')) { die('Access denied'); }
if ($mode == 'get_cart') {
if (defined('AJAX_REQUEST')) {
$cart =& $_SESSION['cart'];
$livechat_cart = array(
'products' => array(),
'value' => $cart['total'] . ' ' . CART_PRIMARY_CURRENCY
);
foreach ($cart['products'] as $product) {
$livechat_cart['products'][] = array(
$product['product'],
$product['amount'],
fn_url('products.view?product_id=' . $product['product_id'])
);
}
Registry::get('ajax')->assign('livechat_cart', $livechat_cart);
exit;
}
}
Please help.

Contact the addon developer. I don't believe there is a standard "Live chat" addon.

Contact the addon developer. I don't believe there is a standard "Live chat" addon.

Thanks for your quick reply.

I just contact with them and as they mentioned to uninstall and re-install the addon. but still the problem.

they ask me to contact the sever.

the livechat support team reply below:

Notice Undefined Index in PHP is an error which occurs when you try to access the value or variable which does not exist.
There seems to be some kind of reference to a nonexistent variable on your server-side.
From what I can see the LiveChat widget is properly displayed on your website and there are no errors related to LiveChat in the console.
I'm afraid you need to check that on your server side, unfortunately, we can't help much here.

--------------------------------------------------

The server administrator told me that:

Unfortunately, this has nothing with the server configuration, according to the code in /home/XXXXXX/public_html/app/addons/livechat/controllers/frontend/livechat.php

'value' => $cart['total'] . ' ' . CART_PRIMARY_CURRENCYThe index 'total' isn't defined. It's hard to say how critical it is for this addon functioning, however, PHP notices have no impact in general.

----------------------------------------------

So I don`t know what to do and how to resolve it.

the error_log increased very fast.about 20M everyday.

Please help.

Tell them it's a defect and you would like it fixed. Doesn't matter if it's a notice, warning or error, the code is not behaving properly. Optionally uninstall and choose a different vendor who is more willing to support their product.

OK thank you.

I just ask the server to disable the notice,because livechat don`t want to resolve it. really hard to communicate with them.

Tell them it's a defect and you would like it fixed. Doesn't matter if it's a notice, warning or error, the code is not behaving properly. Optionally uninstall and choose a different vendor who is more willing to support their product.

Try to replace

$cart =& $_SESSION['cart'];

with

$cart = &Tygh::$app['session']['cart'];

Thank you .i`ll have a try and let you the result.

Before i change the code,there is an new error.

[09-Mar-2022 13:53:08 Asia/Shanghai] PHP Warning: Invalid argument supplied for foreach() in /home/xxxxx/public_html/app/addons/livechat/controllers/frontend/livechat.php on line 15

Try to replace

$cart =& $_SESSION['cart'];

with

$cart = &Tygh::$app['session']['cart'];