WC_Email_Customer_Preview_Approved

Customer Request Texts Email.

Defined (1)

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

/includes/class-wc-email-customer-preview-approved.php  
  1. class WC_Email_Customer_Preview_Approved extends WC_Email { 
  2.  
  3. /** 
  4. * Set email defaults 
  5. * @since 0.1 
  6. */ 
  7. public function __construct() { 
  8.  
  9. // set ID, this simply needs to be a unique name 
  10. $this->id = 'wc_customer_preview_approved'; 
  11.  
  12. // this is the title in WooCommerce Email settings 
  13. $this->title = __( 'Customer Preview Approved', 'woo_af2p' ); 
  14.  
  15. // this is the description in WooCommerce email settings 
  16. $this->description = __( 'Customer Preview Approved emails are sent when a preview document was approved', 'woo_af2p' ); 
  17.  
  18. // these are the default heading and subject lines that can be overridden using the settings 
  19. $this->heading = __( 'Preview Approved', 'woo_af2p' );; 
  20. $this->subject = __( 'Preview Approved', 'woo_af2p' );; 
  21.  
  22. // these define the locations of the templates that this email should use, we'll just use the new order template since this email is similar 
  23. $this->template_base = untrailingslashit( dirname(plugin_dir_path( __FILE__ ) ) ) . '/templates/'; 
  24. $this->template_html = 'emails/customer-preview-approved.php'; 
  25. $this->template_plain = 'emails/plain/customer-preview-approved.php'; 
  26.  
  27. // Trigger on new paid orders 
  28. add_action( 'woocommerce_af2p_status_awaiting-approval_to_preview-approved', array( $this, 'trigger' ) ); 
  29.  
  30. // Call parent constructor to load any other defaults not explicity defined here 
  31. parent::__construct(); 
  32.  
  33.  
  34. /** 
  35. * Determine if the email should actually be sent and setup email merge variables 
  36. * @since 0.1 
  37. * @param int $order_id 
  38. */ 
  39. public function trigger( $order_id ) { 
  40.  
  41. error_log('Trigger inside'); 
  42.  
  43. // bail if no order ID is present 
  44. if ( ! $order_id ) 
  45. return; 
  46.  
  47. // setup order object 
  48. $this->object = new WC_Order( $order_id ); 
  49. $this->recipient = $this->object->billing_email; 
  50.  
  51. // bail if shipping method is not expedited 
  52. //if ( ! in_array( $this->object->get_shipping_method(), array( 'Three Day Shipping', 'Next Day Shipping' ) ) ) 
  53. // return; 
  54.  
  55. // replace variables in the subject/headings 
  56. $this->find[] = '{order_date}'; 
  57. $this->replace[] = date_i18n( woocommerce_date_format(), strtotime( $this->object->order_date ) ); 
  58.  
  59. $this->find[] = '{order_number}'; 
  60. $this->replace[] = $this->object->get_order_number(); 
  61.  
  62. if ( ! $this->is_enabled() || ! $this->get_recipient() ) 
  63. return; 
  64.  
  65. // woohoo, send the email! 
  66. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); 
  67. }  
  68.  
  69.  
  70. /** 
  71. * get_content_html function. 
  72. * @since 0.1 
  73. * @return string 
  74. */ 
  75. public function get_content_html() { 
  76. ob_start(); 
  77. woocommerce_get_template( $this->template_html, array( 
  78. 'order' => $this->object,  
  79. 'email_heading' => $this->get_heading() 
  80. ) ); 
  81. return ob_get_clean(); 
  82.  
  83.  
  84. /** 
  85. * get_content_plain function. 
  86. * @since 0.1 
  87. * @return string 
  88. */ 
  89. public function get_content_plain() { 
  90. ob_start(); 
  91. woocommerce_get_template( $this->template_plain, array( 
  92. 'order' => $this->object,  
  93. 'email_heading' => $this->get_heading() 
  94. ) ); 
  95. return ob_get_clean(); 
  96.  
  97. /** 
  98. * Initialize Settings Form Fields 
  99. * @since 0.1 
  100. */ 
  101. public function init_form_fields() { 
  102.  
  103. $this->form_fields = array( 
  104. 'enabled' => array( 
  105. 'title' => __( 'Enable/Disable', 'woocommerce' ),  
  106. 'type' => 'checkbox',  
  107. 'label' => __( 'Enable this email notification', 'woocommerce' ),  
  108. 'default' => 'yes' 
  109. ),  
  110. 'subject' => array( 
  111. 'title' => __( 'Subject', 'woocommerce' ),  
  112. 'type' => 'text',  
  113. 'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: <code>%s</code>.', 'woocommerce' ), $this->subject ),  
  114. 'placeholder' => '',  
  115. 'default' => '' 
  116. ),  
  117. 'heading' => array( 
  118. 'title' => __( 'Email Heading', 'woocommerce' ),  
  119. 'type' => 'text',  
  120. 'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: <code>%s</code>.', 'woocommerce' ), $this->heading ),  
  121. 'placeholder' => '',  
  122. 'default' => '' 
  123. ),  
  124. 'email_type' => array( 
  125. 'title' => __( 'Email type', 'woocommerce' ),  
  126. 'type' => 'select',  
  127. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),  
  128. 'default' => 'html',  
  129. 'class' => 'email_type',  
  130. 'options' => array( 
  131. 'plain' => 'Plain text',  
  132. 'html' => 'HTML', 'woocommerce',  
  133. 'multipart' => 'Multipart', 'woocommerce',  
  134. ); 
  135.  
  136. } // end WC_Email_Customer_Request_Texts class