Jump to content

add a sound when receiving new order


fernandokerber
 Share

Recommended Posts

Im working on a chinese food online store and I'd like to know if anyone knows about any way to play a sound when shop's owner receive new orders.

 

I think It should use Ajax to retrieve new orders information in real time and then play the sound..

 

I appreciate the help

Share this post


Link to post
Share on other sites

The simple way is to use the message sent by mail alerts to trigger a sound and notify you when it is received. Depending on your mail client, you could setup a rule that detects the message and makes a sound on the PC.

  • Like 2

Share this post


Link to post
Share on other sites

You are right about the idea:

 

1) plant an ajax (.js link included) in the back-end

2) when logged in as an admin, the js runs.

3) js has a timer (set to N minute loop) to initialize a request to your php

4) the php scans the database for new orders

5) feedbacks to js

6) if "yes" for new orders, js triggers a jquery to play an .mp3 sound.

 

Actually, one of my client suggested that he might be very interested in having this sound-warning stuff.

 

Are you a developer yourself?

Share this post


Link to post
Share on other sites

You are right about the idea:

 

1) plant an ajax (.js link included) in the back-end

2) when logged in as an admin, the js runs.

3) js has a timer (set to N minute loop) to initialize a request to your php

4) the php scans the database for new orders

5) feedbacks to js

6) if "yes" for new orders, js triggers a jquery to play an .mp3 sound.

 

Actually, one of my client suggested that he might be very interested in having this sound-warning stuff.

 

Are you a developer yourself?

 

yeah

 

maybe I could delevop something like that... but not in a 'module style'...

 

I can implement this to my store changing some core files, but I dont know how to create a module to do this

Edited by fernandokerber (see edit history)

Share this post


Link to post
Share on other sites

yeah

 

maybe I could delevop something like that... but dont in a 'module style'...

 

I can implement this to my store changing some core files, but I doesnt know how to create a module to do this

 

 

lol~ I am still new to module development on Prestashop but on my way.

 

As I went through some tutorials on this official site, I came cross something about "hook". There might be a hook for you to listen to the event of the incoming updated order. If so, the process will be a lot easier.

 

Otherwise, ajax to check the order updates. And I agree with you that a simple php authorized with database access will do. No module. hehe.

 

Good luck, mate.

Share this post


Link to post
Share on other sites

lol~ I am still new to module development on Prestashop but on my way.

 

As I went through some tutorials on this official site, I came cross something about "hook". There might be a hook for you to listen to the event of the incoming updated order. If so, the process will be a lot easier.

 

Otherwise, ajax to check the order updates. And I agree with you that a simple php authorized with database access will do. No module. hehe.

 

Good luck, mate.

 

 

I read something about hooks too, but not too much specific to solve my problem...

 

there is a "new-order" hook, right?

 

what does this hook actually do? how does it works in fact?

 

 

it would call a function after the users checkout? and then...?

Share this post


Link to post
Share on other sites

You should look into just setting up a thunderbird, or outlook to auto print the emails of the invoices. There are plugins for this. I like hearing my printers going off :)

 

I wrote a free ups xml modual thats on this site. You can do simlar with the auto print and setup the email clent to save attachments like the xml file for worldship input file so you can get the shipping lables also automated printed out along with the invoice.

Share this post


Link to post
Share on other sites

I read something about hooks too, but not too much specific to solve my problem...

 

there is a "new-order" hook, right?

 

what does this hook actually do? how does it works in fact?

 

 

it would call a function after the users checkout? and then...?

 

a "hook" just allows you to respond to certain events that occur on your site. the newOrder hook allows you to respond to a new order being created. so yo

u would create a module that listens for the newOrder hook, and then react in some way.i

 

I like Rhapsody's approach, but it assumes you are running an email client that can play a sound based on receiving an email.

Share this post


Link to post
Share on other sites

I’ve to do the same for a client as well in future months, :))

I think your best bet’d be to use orderConfirmation hook instead of new order one because if I am not wrong it’ll be triggered once an order proceeds and not necessarily confirmed.

and by the way using email APIs doesn’t look enough reliable I think, although it would looks easier to do but it’s more dependence on third parties and I can imagine would add some delay of notifications and difficulties on debugging level as well, but you know you have to see if other technics just working or not!

And I think also using a module in backoffice would be better than changing the PS cores since I guess it’s possible all the way, ;)

Edited by mim (see edit history)

Share this post


Link to post
Share on other sites

In prestashop version 1.5 which I checked, there is a notification option in the back-end:

 

Administration Tag -> Preferences -> Notifications.

 

You can put a tick to "Show notifications for new orders"...

 

Then, you know what to do. Perhaps override that thing and put a jquery sound to it. Haha~

Share this post


Link to post
Share on other sites

I think the files which need to me modified for this new function are: Notification.php and Notification.js - Available in prestahsop 1.5

I made some tries ...but no chance for my knowledge. Maybe somebody will help us with a response.

Share this post


Link to post
Share on other sites

I was thinking about using my email client to do that, but as "mim" said, I could have trouble with delays and mail failures.

 

I'll take a look at all your suggestions refering to use the 1.5 native features and/or hook functions for 1.4.x versions.

 

 

By the way, what's the difference between the orderConfirmation hook and the newOrder hook? When each one starts working?

 

Thanks

Share this post


Link to post
Share on other sites

the newOrder hook is executed after you click the confirm order button, and after the payment module has performed its functions. However it is before the customer is redirected to the order confirmation page is displayed. It is easier to say that once the order is created in the database, the newOrder hook is executed.

 

The orderConfirmation hook is executed when the customer is redirected to the order confirmation page.

  • Like 1

Share this post


Link to post
Share on other sites

I think the files which need to me modified for this new function are: Notification.php and Notification.js - Available in prestahsop 1.5

I made some tries ...but no chance for my knowledge. Maybe somebody will help us with a response.

 

I looked up the Notification.js, I believe it is quite easy to facilitate it with a sound. We need to re-write the Notification.js with jquery plugin. Here we choose jquery.jmp3.js (you may google it), modify the jmp3 a bit about the path of swf/flash player (you may put it right next to the js file), switch it to autoplay.

 

In the Notification.js, we put add a line of soundTrigger() there:

 

function getPush(refresh)
{
$.post("ajax.php",{"getNotifications" : "1"}, function(data) {
if (data)
{

soundTrigger();

 

......

 

Write a function according to jmp3's way and get the sound autoplayed. That's it.

Share this post


Link to post
Share on other sites

I looked up the Notification.js, I believe it is quite easy to facilitate it with a sound. We need to re-write the Notification.js with jquery plugin. Here we choose jquery.jmp3.js (you may google it), modify the jmp3 a bit about the path of swf/flash player (you may put it right next to the js file), switch it to autoplay.

 

In the Notification.js, we put add a line of soundTrigger() there:

 

function getPush(refresh)
{
$.post("ajax.php",{"getNotifications" : "1"}, function(data) {
if (data)
{

soundTrigger();

 

......

 

Write a function according to jmp3's way and get the sound autoplayed. That's it.

 

 

hi!

I'm trying these notifications but agreeing with my tests, it's not a self refreshing functionality, right?

 

I've checked the 'new order' and 'new account' notification, and I made a new order by myself but the notification didn't appear in my back-end automatically (like Facebook does).

 

It just appeared when I did a refresh by myself in the the back-end (clicking in any link in the back-end).

Share this post


Link to post
Share on other sites

hi!

I'm trying these notifications but agreeing with my tests, it's not a self refreshing functionality, right?

 

I've checked the 'new order' and 'new account' notification, and I made a new order by myself but the notification didn't appear in my back-end automatically (like Facebook does).

 

It just appeared when I did a refresh by myself in the the back-end (clicking in any link in the back-end).

 

Please take a look at rows : 44-45 // getPush(autorefresh_notifications); and

114-115// if(refresh)

setTimeout("getPush(1)",60000);

from file notification.js.

I THINK we can modify the 60000 value and add a new one. This change will make a new refresh according with what value we set there.

I would be happy to see this post as RESOLVED.

 

I found this : you can add at the final of the code of the file which you want to be refresded

echo('<meta http-equiv="refresh" content="6000">');

Edited by gabryel80 (see edit history)

Share this post


Link to post
Share on other sites

Please take a look at rows : 44-45 // getPush(autorefresh_notifications); and

114-115// if(refresh)

setTimeout("getPush(1)",60000);

from file notification.js.

I THINK we can modify the 60000 value and add a new one. This change will make a new refresh according with what value we set there.

I would be happy to see this post as RESOLVED.

 

I found this : you can add at the final of the code of the file which you want to be refresded

echo('<meta http-equiv="refresh" content="6000">');

 

 

 

hi!

nice approach. I tried to modify this value to 1000 milliseconds without any success in self refresh the notifications.

 

I saw a commented line that says "// call it once immediately, then use setTimeout if refresh is activated".

 

I think we need to activate the 'refresh'. But I dont know how to do it

Share this post


Link to post
Share on other sites

I was thinking about how to make the refresh be automatic and i've got a solution!!!

 

In the end of notification.js we need to comment a line that tests a condition.

 

the line is (before):

if(refresh)
setTimeout("getPush(1)",600000);

 

After editing the line and set a smaller time we got:

//if(refresh)
setTimeout("getPush(1)",10000);

Doing this, we make its self refreshing.

  • Like 1

Share this post


Link to post
Share on other sites

  • 1 year later...

Hello ,

I also need sound when recieving order.

Is this working with "setTimeout("getPush(1)",10000);"

WE must write to Prestashop developers to make module about this.

 

:)

Share this post


Link to post
Share on other sites

  • 2 months later...

i was editing the wrong files

here is the solution in 3 steps :

1/ correct an error in the database : PS_ADMIN_REFRESH_NOTIFICATION is the correct name, an '_' has been forgotten.

2/ add in the header.tpl (between the body tags of course) (adminxxx/your_theme/template/ directory) :

     <audio id="the_id">
    <source src="path/to/the/file.mp3" type="audio/mpeg">
    </audio>

    for more about audio tag, please see : http://www.w3schools.com/html/html5_audio.asp

3/ add, in notification.js ( js/ directory), inside the if (html != "")'s braces after $.each(json.order, function(property, value) :

    document.getElementById("the_id").play();

     BUT it will be played every xx ms (set in setTimeout) until there's no more notification displayed

Edited by rhayy (see edit history)

Share this post


Link to post
Share on other sites

  • 7 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...

Important Information

Cookies ensure the smooth running of our services. Using these, you accept the use of cookies. Learn More