WooCommerce_Delivery_Notes_Writepanel

The WooCommerce Print Invoices & Delivery Notes WooCommerce Delivery Notes Writepanel class.

Defined (1)

The class is defined in the following location(s).

/classes/class-wcdn-writepanel.php  
  1. class WooCommerce_Delivery_Notes_Writepanel { 
  2.  
  3. /** 
  4. * Constructor 
  5. */ 
  6. public function __construct() { 
  7.  
  8. /** 
  9. * Load the class 
  10. */ 
  11. public function load() { 
  12. add_action( 'admin_init', array( $this, 'load_hooks' ) ); 
  13.  
  14. /** 
  15. * Load the admin hooks 
  16. */ 
  17. public function load_hooks() {  
  18. add_action( 'woocommerce_admin_order_actions_end', array( $this, 'add_listing_actions' ) ); 
  19. add_action( 'add_meta_boxes_shop_order', array( $this, 'add_box' ) ); 
  20. add_action( 'admin_print_scripts', array( $this, 'add_scripts' ) ); 
  21. add_action( 'admin_print_styles', array( $this, 'add_styles' ) ); 
  22.  
  23. /** 
  24. * Add the styles 
  25. */ 
  26. public function add_styles() { 
  27. if( $this->is_order_edit_page() ) { 
  28. wp_enqueue_style( 'thickbox' ); 
  29. wp_enqueue_style( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'css/style.css' ); 
  30.  
  31. /** 
  32. * Add the scripts 
  33. */ 
  34. public function add_scripts() { 
  35. if( $this->is_order_edit_page() ) { 
  36. ?> 
  37. <script type="text/javascript"> 
  38. var show_print_preview = 'no'; 
  39. </script> 
  40. <?php  
  41. wp_enqueue_script( 'media-upload' ); 
  42. wp_enqueue_script( 'thickbox' ); 
  43. wp_enqueue_script( 'woocommerce-delivery-notes', WooCommerce_Delivery_Notes::$plugin_url . 'js/script.js', array( 'jquery', 'media-upload', 'thickbox' ) ); 
  44. }  
  45.  
  46. /** 
  47. * Is order page 
  48. */ 
  49. public function is_order_edit_page() { 
  50. global $post_type; 
  51. if( $post_type == 'shop_order' ) { 
  52. return true;  
  53. } else { 
  54. return false; 
  55. }  
  56.  
  57. /** 
  58. * Add print actions to the orders listing 
  59. */ 
  60. public function add_listing_actions( $order ) { 
  61. ?> 
  62. <a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $order->id ), 'generate_print_content' ); ?>" class="button tips print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>"> 
  63. <span><?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?></span> 
  64. <img src="<?php echo WooCommerce_Delivery_Notes::$plugin_url . 'images/print-invoice.png'; ?>" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" width="14"> 
  65. </a> 
  66. <a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=delivery-note&order_id=' . $order->id ), 'generate_print_content' ); ?>" class="button tips print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" data-tip="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>"> 
  67. <span><?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?></span> 
  68. <img src="<?php echo WooCommerce_Delivery_Notes::$plugin_url . 'images/print-delivery-note.png'; ?>" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>" width="14"> 
  69. </a> 
  70. <img src="<?php echo admin_url( 'images/wpspin_light.gif' ); ?>" class="loading" alt=""> 
  71. <?php 
  72.  
  73. /** 
  74. * Add the meta box on the single order page 
  75. */ 
  76. public function add_box() { 
  77. add_meta_box( 'woocommerce-delivery-notes-box', __( 'Order Print', 'woocommerce-delivery-notes' ), array( $this, 'create_box_content' ), 'shop_order', 'side', 'default' ); 
  78.  
  79. /** 
  80. * Create the meta box content on the single order page 
  81. */ 
  82. public function create_box_content() { 
  83. global $post_id; 
  84. ?> 
  85. <ul class="woocommerce-delivery-notes-actions"> 
  86. <li><a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=invoice&order_id=' . $post_id ), 'generate_print_content' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Invoice', 'woocommerce-delivery-notes' ); ?></a></li> 
  87. <li><a href="<?php echo wp_nonce_url( admin_url( 'admin-ajax.php?action=generate_print_content&template_type=delivery-note&order_id=' . $post_id ), 'generate_print_content' ); ?>" class="button print-preview-button" target="_blank" alt="<?php esc_attr_e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?>"><?php _e( 'Print Delivery Note', 'woocommerce-delivery-notes' ); ?></a></li> 
  88. </ul> 
  89. <img src="<?php echo admin_url( 'images/wpspin_light.gif' ); ?>" class="loading" alt=""> 
  90. <?php 
  91.