Product not added to the cart

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
1 year 3 months ago #347975

-- HikaShop version -- : 4.7.0
-- Joomla version -- : 4.2.6
-- PHP version -- : 8

Hi,

Oddly I am getting the message "Product not added to the cart" when trying to add ANY product to the cart. There has been no changes so I', confused as to why this has suddenly started happening.

I have tried the following:
No limits set
Cart features enabled
Removed Overrides
Checked Stock - all unlimited
Maximum number of items in the cart - unlimited
Changed template to default
Disabled the Notification plugin

What could I be missing please?

Last edit: 1 year 3 months ago by grayt7.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 3 months ago #347981

Hi,

That error message "Product not added to the cart" is quite rare.
It means that something cancelled the add to cart process without any error message and thus HikaShop displays a generic message.
In the HikaShop add to cart process, as far as I know, there is always an error message provided when it needs to cancel the add to cart process. The message is usually different based on what cancels it. If it's a limit for example, the message would be "Limit reached. You can't add more than XX items for the product YY." This normally allows us (and usually the merchant/customer) to know what caused the add to cart to fail.
Now, any plugin of the group hikashop or system can potentially cancel an add to cart for one reason or another, and if it doesn't provide an error message, then, HikaShop will display that generic message.
So I'm thinking it might be the case here. Do you have any custom plugin integrating with the add to cart process ? Or third party extensions integrating with HikaShop, like AWOCoupon ? I see you had HikaAuction and HikaMarket but your subscriptions expire. So if you still have them on the website, it would mean you have old versions of them and it might be related to that.
If you have a doubt on a plugin, try deactivating it and see if it helps. If it does, then you'll know it's linked to it.
If all of this bears no result, then we would need a FTP access to do some debugging to find out what is cancelling the add to cart process.

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 3 months ago #348018

Hi,

It seems to be an issue with the database.
I've added some debug in administrator/components/com_hikashop/helpers/helper.php in the save function which handles adding and updating elements to the database.

I've made it so that it logs any insert MySQL query (for new elements, like a new cart), then, logs the result of the MySQL query, and finally logs the id resulting.
So the code is basically like this:

			hikashop_writeToLog($query);
			$this->database->setQuery($query);
			$status = $this->database->execute();
			hikashop_writeToLog($status);
...
			$id = $this->database->insertid();
			hikashop_writeToLog('last id:'.$id);

At the end of your HikaShop log, I get this when I do an add to cart:
<h3>01.05.23 15:17:45</h3>
INSERT IGNORE INTO `#__hikashop_cart` ( `user_id`,`session_id`,`cart_currency_id`,`cart_params`,`cart_share`,`cart_type`,`cart_current`,`cart_modified` ) VALUES ( '0','d414eb9a9651a1b8955de04281319d85','4','{}','nobody','cart','1','1672931865' ) 
<h3>01.05.23 15:17:45</h3>
1
<h3>01.05.23 15:17:45</h3>
last id:0
So first the MySQL query is correct. And if I run it in your PHPMyAdmin (after changing the prefix), I do get the cart entry added in the hikashop_cart table.
Then, the "1" indicates that MySQL successfully executed the query.
But the "last id:0" means that MySQL returned 0 instead of the cart_id of the new cart.

This could indicate that the hikashop_cart table is missing the primary key / auto_increment.
So I checked that table in your PHPMyAdmin but I can see the primary key on cart_id and the auto_increment on it:
i.imgur.com/FS3wNQH.png
What's strange is that the entry in the hikashop_cart table has not been added, even though the execute function returned a success.

Now, looking a bit online about this, I found this:
joomla.stackexchange.com/questions/5754/...ast-inserted-id/5768
It seems to match with the situation. However, in these cases, the entry is added in the database, which isn't the case on your end.

Also, it could potentially be a system plugin which would override the Joomla MySQL driver to run a SELECT query right after the INSERT query for some reason, leading to the insertid() function to fail. I know Falang has a driver override working in a similar way (but it doesn't cause issues because it only works on SELECT queries, not UPDATE or INSERT queries). However, I couldn't find a plugin which looked suspicious on your website regarding this.

So basically, I'm not sure what is the problem. It seems to be linked to the configuration of your database, but I'm not sure what it could be. I would recommend checking with your hosting support.
Also, if you can make a copy of the website on another hosting (or a local XAMP), you could verify that everything still works fine, which would confirm that it comes from something on the server side.

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

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
1 year 3 months ago #348205

Hi Nicolas,

First of all, thank you very very much for doing all this work to try to find the problem. I have been in talks with the host the last few days. They are adamant that there is nothing wrong with the database.

I will try a copy of the site on alternative hosting.

Thank you.

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

  • Posts: 356
  • Thank you received: 7
  • Hikashop Business
1 year 3 months ago #348690

Hi,

this issue was finally resolved by the hosts. they did not give a reason why it was a problems which awas frustrating. The site worked fine for 6 days and now for some reason the IPN for worldpay and paypal seems to work fine, but the transaction ID is not recroded even though the order is put unto a confirmed state.

You can use the same details as previously sent if you need to login.

Many thanks,

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

  • Posts: 81540
  • Thank you received: 13071
  • MODERATOR
1 year 3 months ago #348706

Hi,

I don't see how the paypal plugin could automatically confirm the order without adding the transaction id to the history of the order.

You did provide a FTP access previously, but not a backend access. I would need a backend access to check the situation there first.
Could you provide that ?

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

Time to create page: 0.055 seconds
Powered by Kunena Forum