run action on status update (admin)

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #4085
    Olly
    Admin & Mod

      example. when you change the status of an order to PROCESSED you could automatically open the print dialog to print it somewhere .
      if you want to do something else on change of status , change as required.

      
      add_action('admin_footer', 'wppizza_print_processed_orders');
      function wppizza_print_processed_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($){
      $(document).on('change', '.wppizza_order_status', function(e){
      var self=$(this);
      var selId=self.attr('id').split('-').pop(-1);
      var selfVal=self.val();
      /* do things when you change the status to PROCESSED, in this case trigger the print button **/
      if(selfVal=='PROCESSED'){
      var triggerTarget=$('#wppizza-print-order-'+selId+'');
      triggerTarget.trigger('click');
      }
      });
      });
      /* ]]> */
      </script>";
      }
      }
      
    Viewing 1 post (of 1 total)
    • The topic ‘run action on status update (admin)’ is closed to new replies.