Alert sound with incoming order

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 6 months ago #341860

Hi,

Again, I was not able to reproduce the problem:
i.imgur.com/hnz2llC.png
Whenever I was doing my tests I got the notification box directly and it worked great on your website.

So I run some more tests and at one point I was able to reproduce the problem. It didn't work when the developer tools area was closed (so that's why you got the issue and I didn't since I normally need the developer tools of the browser to understand what's going on and normal users usually don't have it open).

So I first thought that it might be a limitation of browsers blocking ajax requests in some cases to save resources. But I couldn't find any information on that online.

And while doing my tests, I noticed that for each "check" request, there was a second row in the network log of the developer tools with something coming from the file /pwa_maker_service_worker.js of your website.
At first, I thought it was another extension doing its thing on the side and didn't pay mind to it. Foremost, the javascript code in there is trimmed so it's hard to read so I didn't bother.
But since that was my only clue, I tried to look deeper into it. And it turns out this file has some code to catch all the AJAX requests made on your website and cache them on the browser so that they are not really made but the content is retrieved from the cache.
So that's the second problem you have there:
i.imgur.com/CRj7FIy.png
This file prevents the notifications from poping because it gives a cached version of the check ajax request's response and thus it doesn't see the new order coming in.
Looking at the code, I can see that it does this only for GET requests. So I've changed the code in the plugin to do a POST request and now it works even with the developers tools closed on my end.
So I suppose the problem is fixed ( note that you need to clear your browser's cache to see the change). But really it was a hard one to find and I don't see why it needs to cache all the GET requests like that :/

Now regarding the refresh thing, to circumvent the problem, you can change the line:
window.last_interaction = 0;
to:
window.last_interaction = Date.now();
in the file plugins/system/ordernotify/media/notify.js and clear your browser's cache.
That way, it will start the check process when any page is loaded and thus it will work even if the page is reloaded and no one touches it.

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
2 years 6 months ago #341868

Hi Nicolas,

This works now like charme as far i can see during my tests.
Super..
But i now want to put it on our live site.. so where did you change this??

Looking at the code, I can see that it does this only for GET requests. So I've changed the code in the plugin to do a POST request and now it works even with the developers tools closed on my end.


So then i can upload the plugin and make these changes also and put it to work.. :)

Thanks.

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
2 years 6 months ago #341870

Hi,

The modification has been added on our end too.
So if you download the install package of the plugin on our website, you'll get the fix.
Also, the file plugins/system/ordernotify/media/notify.js contains the fix so you could just copy it from one website to the other.

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

  • Posts: 410
  • Thank you received: 9
  • Hikaserial Subscription Hikashop Business
2 years 5 months ago #341950

Hi Nicolas,

Super this works like a charme we are very happy.
Thanks a lot for the help..
Regards,
Mark

The following user(s) said Thank You: nicolas

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

Time to create page: 0.059 seconds
Powered by Kunena Forum