Cart not refresh when adding a product

  • Posts: 363
  • Thank you received: 28
  • Hikashop Multisite
2 years 10 months ago #341147

-- url of the page with the problem -- : tango-express.ch/nos-produits/produits/1-produit-test-1
-- HikaShop version -- : 4.5.1
-- Joomla version -- : 4.1.2
-- PHP version -- : 8.0

Hi,
I have a problem when adding a product in the cart. The cart dos not refresh with the product. I have to refresh manually the web page to see the amount in cart.

Go to the page : tango-express.ch/nos-produits/produits/1-produit-test-1
(connect with credentials below)

This message contains confidential information


Clic on "Ajouter au panier".
Expected result = Cart refresh with amount and a message "product added to cart".

Actual result = nothing. Have to reload the webpage to see the cart updated.


“Si tu ne travaille pas pour tes rêves, quelqu'un t'embauchera pour travailler pour les siens" - Steeve Jobs
"La sagesse, c’est d’avoir des rêves suffisamment grands pour ne pas les perdre de vue quand on les poursuit." - Oscar Wilde

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

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
2 years 10 months ago #341156

Hi,

When you click on the add to cart button, the browser sends an AJAX request to the server, and based on the json data returned, it will refresh the cart module, display a notification popup, and/or redirect to the checkout. This problem here is that nothing is returned and thus nothing is done as it doesn't know what's going on.
If you look at the console of your browser while you click on the add to cart button, you can see this:
i.imgur.com/khXmy61.png
So the add to cart HTTP request to the server returns successfully (indicating that the add to cart has been done), but the response cannot be read back by the browser which leads to a ERR_CONTENT_DECODING_FAILED error.
Searching a bit online ( stackoverflow.com/questions/14039804/err...tent-decoding-failed ) this is indicative of an issue linked to gzip compression.
If you access the URL tango-express.ch/nos-produits/product/up...add-1/cid-1?tmpl=raw
you'll get the same thing as if you click on the add to cart button.
Normally, this should display in the browser some json data with information about the add to cart being successful.
However, nothing appears.
And if I check the network area, I can see that the request stays in "pending":
i.imgur.com/kI2ndFB.png
This means usually that the browser is waiting for the server to send back the data.
Looking a bit online about it, I found this page:
serverfault.com/questions/708319/chrome-...ts-get-stuck-pending
There is says that forcing the connection to close might help.
You can try by adding the line:

header('Connection: close');
after the line
public function updatecart() {
in the file components/com_hikashop/controllers/product.php
Also, it might be something linked to a PHP error. so checking the PHP error log of the server might be a good idea.

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

  • Posts: 363
  • Thank you received: 28
  • Hikashop Multisite
2 years 10 months ago #341162

Hi,
thank you for this explanation and support. But it dos not work.

That i dont understand is why in this site it work : test-dev.ch/index.php/categories/product/128-produit-test-dev
Same server, same installation.

I have to understand what can cause this issue on the new site.

I see this message in the log many time :

This message contains confidential information


The only difference is i used the auto installer for Joomla from my host on my new site. I will try to make a new installation manually in another folder to see.

EDIT : No it dos not wort...


“Si tu ne travaille pas pour tes rêves, quelqu'un t'embauchera pour travailler pour les siens" - Steeve Jobs
"La sagesse, c’est d’avoir des rêves suffisamment grands pour ne pas les perdre de vue quand on les poursuit." - Oscar Wilde
Last edit: 2 years 10 months ago by thefbi.

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

  • Posts: 363
  • Thank you received: 28
  • Hikashop Multisite
2 years 10 months ago #341166

If i put PHP 7.4, it work.
If PHP 8.0 or 8.1 = dos not work...

Actually 7.4 and as you can see it work.
But work in my test site with 8.0 ( test-dev.ch/categories/product/128-produit-test-dev )


“Si tu ne travaille pas pour tes rêves, quelqu'un t'embauchera pour travailler pour les siens" - Steeve Jobs
"La sagesse, c’est d’avoir des rêves suffisamment grands pour ne pas les perdre de vue quand on les poursuit." - Oscar Wilde
Last edit: 2 years 10 months ago by thefbi.

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

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
2 years 10 months ago #341165

Hi,

What I wrote above are just what I could figure out looking at the situation on the new website.

But it's interesting that this works on another website on the same server and even that it works on the website with a different version of PHP.
So now the question is : what is different between both websites ?
Do you have extensions you installed on one and not on the other ? Did you configure some extensions differently between both websites ? Did you change the htaccess for one website differently from what you did on the other ?

The error in your log indicates that the server denied access to a page of the website because of either a htaccess or the configuration of apache:
serverfault.com/questions/801325/authz-c...keeps-denying-access
It could be linked, but it could also be unrelated. It's hard to say.
The best would be to look at the log before adding something to the cart and after and see if you get an extra message like this in the log at that point. That would confirm that it's linked to the problem and thus it would point at a configuration issue in apache.

Also, if changing the version of PHP fixes the issue, it's likely to come from a warning/notice/fatal error. So normaly, that should be logged in the PHP error log of the server. I would recommend you to look into it (the log you provided in the apache error log, not the PHP error log).

Last edit: 2 years 10 months ago by nicolas.

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

  • Posts: 363
  • Thank you received: 28
  • Hikashop Multisite
2 years 10 months ago #341177

Hi, ok, i will have to find where is the php error log. On my server management i have only the apache error log.

That is strange is i have add another folder to the new website and juste put a fresh installation of Joomla.
After that, i just put Hikashop and my template system (Nicepage) to it. Nothing else. And it still dont work.
So at this point i can say that is not related to an extension.

I usually install Admin Tools wich change the htaccess of the site. But i tested to totally uninstall it in the new site and still dont work.

I have a cloud managed server, and i can add hosting on it. In the hosting, i can add sites. So the site wich work is on the same server, but on a other hosting.

I will try another thing, i will backup the actual new site (with all extensions and config) to put it on the test-dev server to see if it work or not.

EDIT : It work on the test-dev hosting.


“Si tu ne travaille pas pour tes rêves, quelqu'un t'embauchera pour travailler pour les siens" - Steeve Jobs
"La sagesse, c’est d’avoir des rêves suffisamment grands pour ne pas les perdre de vue quand on les poursuit." - Oscar Wilde
Last edit: 2 years 10 months ago by thefbi.

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

  • Posts: 363
  • Thank you received: 28
  • Hikashop Multisite
2 years 10 months ago #341178

You now what, i will leave the site in this hosting and stop losing your time and mine to find the problem.
I have to go forward on this project.

I will try to ask my host to know if we can see the difference between the 2 hosting.
EDIT : i asked my host and we will try to find what is the problem.

I will come back here to say the results.


“Si tu ne travaille pas pour tes rêves, quelqu'un t'embauchera pour travailler pour les siens" - Steeve Jobs
"La sagesse, c’est d’avoir des rêves suffisamment grands pour ne pas les perdre de vue quand on les poursuit." - Oscar Wilde
Last edit: 2 years 10 months ago by thefbi.

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

  • Posts: 83402
  • Thank you received: 13495
  • MODERATOR
2 years 10 months ago #341179

Hi,

Ok. Also, I would recommend sending a message to your hosting support to find out where the PHP error log is.
Even if it doesn't bring any information here, it's always nice to know where it is to have a quick look at it when you stumble on an issue. It can oftn lead to a solution.

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

Time to create page: 0.069 seconds
Powered by Kunena Forum