WPPizza – A Restaurant Plugin for WordPress › Support › Code Snippets WPPizza v2.x (read only)
(Code Snippets for v3.x) › play sound when new order arrives (admin)
- AuthorPosts
- 12 June, 2014 at 3:03 pm #4024
Note by admin: the below is completely irrelevant with WPPizza v3.x+ – as it’s inbuilt as an option – and only here for historical reasons (i.e if still using WPPizza 2.x)
if you are too busy to look at your emails/order history all the time, you could also play a sound when a new order arrives if you like that sort of thing … (put it in your theme’s functions.php)
/************************************************************************* play sound on new order in order history. repeats every 5 sec (5000 ms) until there's no new order anymore (just change the status).... set timeout (5000) to whatever timeinterval is required set soundfile (notifySound): URL to whatever sound is supposed to be played if using IE, use an mp3 file instead of .wav ***************************************************************************/ add_action('admin_footer', 'wppizza_notify_new_orders'); function wppizza_notify_new_orders(){ global $current_screen; if(isset($current_screen) && $current_screen->id=='wppizza_page_wppizza-order-history'){ echo"<script type='text/javascript'> /* <![CDATA[ */ jQuery(document).ready(function($){ var notifySound = '".get_template_directory_uri()."/notify.wav';/* URL to your soundfile */ var notifyNewOrders = new Audio(notifySound); var notifyNewOrdersInterval=setInterval(function(){ if($('.wppizza-ord-status-new').length>0){ notifyNewOrders.play(); }},(5000)); }); /* ]]> */ </script>"; } }
6 July, 2014 at 2:13 pm #4326Perfect. Thanks
11 November, 2014 at 10:54 pm #6135Great this is working, BUT if I make 5000ms the full song is playing AND is it possible not to repeat the song?
Thank you very much
11 November, 2014 at 11:09 pm #6136you are playing a whole song ? are you insane (meaning that in the nicest possible way 🙂 ?
sounds like cacophony
then again, this might be interesting though…maybe there’s an artform to be discovered 😉in any case, you will have to set the settings (timeout etc) according to your soundfiles
the above is an example, it’s up to you to adjust
11 November, 2014 at 11:12 pm #6137essentially , use a short soundfile.
if you change the status , it should not play again (unless of course there’s another order that justifies this soundfile being played again)
again – it’s a sample code/codesnippet. it’s for you to make this work for your situation
3 June, 2015 at 5:19 pm #10393Where do we put this little piece of code?
4 June, 2015 at 8:59 am #10400(put it in your functions.php)
11 August, 2015 at 7:18 am #11462AnonymousThis is a great option, but I’m having difficulty getting it to work. I have added this code into the template functions.php and uploaded a sound file – notify.mp3 – using the media library. Have I placed the sound file in the right place?
11 August, 2015 at 7:38 am #11486get_template_directory_uri() refers to your theme directory, either change that code to point to your uploads, or upload the sound file to your theme’s directory
(note: look at the source of your page to see where it points to…..)12 August, 2015 at 3:30 am #11500AnonymousThanks, heaps. Working like a dream.
16 March, 2016 at 12:01 pm #16585Hi Olly
I’ve been having email delays with my email server lately so I’m trying this code but looks like I’m not using the code right. I’ve put the code in my theme’s functions.php
and moved the notify.wav to theme directory .. still dose not workdo I need to point it to the link like this or something ?
var notifySound = ‘”.get_template_directory_uri(www.mydomain.com).”/notify.wav’;Thanks for your help
16 March, 2016 at 12:53 pm #16589sorry, but I know nothing about your server/setup.
you will have to adjust the code as needed in your environment. I cannot help you more than what is already said in this thread or the code provided. - AuthorPosts
- The topic ‘play sound when new order arrives (admin)’ is closed to new replies.