play sound when new order arrives doesn't work

WPPizza – A Restaurant Plugin for WordPress Support General Support play sound when new order arrives doesn't work

Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #23333
    Dallas
    Participant

      Hey Olly,

      I was trying to get the sound notification for new orders to work, but nothing seems to work. I am using a child theme so my code looks like this:

       /*************************************************************************
      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)  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_stylesheet_directory_uri()."/emergency005.wav';
      var notifyNewOrders = new Audio(notifySound);
      var notifyNewOrdersInterval=setInterval(function(){
      if($('.wppizza-ord-status-new').length>0){       
      notifyNewOrders.play();
      }},(5000));
      });
      /* ]]> */
      </script>";
      }
      }
      

      I do have it in my functions.php and the sound file is also the child directory. Any ideas?

      #23338
      Olly
      Admin & Mod

        check what the your script actually outputs ( file paths etc )
        moreover, this will only work on the orderhistory page as it’s coded btw (but you could adjust that )

        i know this works on many installations

        PS: Just a heads-up. this will be actually a clickable option in wppizza v3.x (not much longer until a beta will be made available – just doing some tidy up, testing as much as i can and updating the various extension to work with it)

        #23345
        Dallas
        Participant
          This reply has been marked as private.
        Viewing 3 posts - 1 through 3 (of 3 total)
        • The topic ‘play sound when new order arrives doesn't work’ is closed to new replies.