WC_Email_Customer_Invoice

Customer Invoice.

Defined (1)

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

/includes/emails/class-wc-email-customer-invoice.php  
  1. class WC_Email_Customer_Invoice extends WC_Email { 
  2.  
  3. /** 
  4. * Strings to find in subjects/headings. 
  5. * @var array 
  6. */ 
  7. public $find; 
  8.  
  9. /** 
  10. * Strings to replace in subjects/headings. 
  11. * @var array 
  12. */ 
  13. public $replace; 
  14.  
  15. /** 
  16. * Constructor. 
  17. */ 
  18. public function __construct() { 
  19.  
  20. $this->id = 'customer_invoice'; 
  21. $this->title = __( 'Customer invoice', 'woocommerce' ); 
  22. $this->description = __( 'Customer invoice emails can be sent to customers containing their order information and payment links.', 'woocommerce' ); 
  23.  
  24. $this->template_html = 'emails/customer-invoice.php'; 
  25. $this->template_plain = 'emails/plain/customer-invoice.php'; 
  26.  
  27. $this->subject = __( 'Invoice for order {order_number} from {order_date}', 'woocommerce' ); 
  28. $this->heading = __( 'Invoice for order {order_number}', 'woocommerce' ); 
  29.  
  30. $this->subject_paid = __( 'Your {site_title} order from {order_date}', 'woocommerce' ); 
  31. $this->heading_paid = __( 'Order {order_number} details', 'woocommerce' ); 
  32.  
  33. // Call parent constructor 
  34. parent::__construct(); 
  35.  
  36. $this->customer_email = true; 
  37. $this->manual = true; 
  38. $this->heading_paid = $this->get_option( 'heading_paid', $this->heading_paid ); 
  39. $this->subject_paid = $this->get_option( 'subject_paid', $this->subject_paid ); 
  40.  
  41. /** 
  42. * Trigger the sending of this email. 
  43. * @param int $order_id The order ID. 
  44. * @param WC_Order $order Order object. 
  45. */ 
  46. public function trigger( $order_id, $order = false ) { 
  47. if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { 
  48. $order = wc_get_order( $order_id ); 
  49.  
  50. if ( is_a( $order, 'WC_Order' ) ) { 
  51. $this->object = $order; 
  52. $this->recipient = $this->object->get_billing_email(); 
  53.  
  54. $this->find['order-date'] = '{order_date}'; 
  55. $this->find['order-number'] = '{order_number}'; 
  56.  
  57. $this->replace['order-date'] = wc_format_datetime( $this->object->get_date_created() ); 
  58. $this->replace['order-number'] = $this->object->get_order_number(); 
  59.  
  60. if ( ! $this->get_recipient() ) { 
  61. return; 
  62.  
  63. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); 
  64.  
  65. /** 
  66. * Get email subject. 
  67. * @access public 
  68. * @return string 
  69. */ 
  70. public function get_subject() { 
  71. if ( $this->object->has_status( wc_get_is_paid_statuses() ) ) { 
  72. return apply_filters( 'woocommerce_email_subject_customer_invoice_paid', $this->format_string( $this->subject_paid ), $this->object ); 
  73. } else { 
  74. return apply_filters( 'woocommerce_email_subject_customer_invoice', $this->format_string( $this->subject ), $this->object ); 
  75.  
  76. /** 
  77. * Get email heading. 
  78. * @access public 
  79. * @return string 
  80. */ 
  81. public function get_heading() { 
  82. if ( $this->object->has_status( array( 'completed', 'processing' ) ) ) { 
  83. return apply_filters( 'woocommerce_email_heading_customer_invoice_paid', $this->format_string( $this->heading_paid ), $this->object ); 
  84. } else { 
  85. return apply_filters( 'woocommerce_email_heading_customer_invoice', $this->format_string( $this->heading ), $this->object ); 
  86.  
  87. /** 
  88. * Get content html. 
  89. * @access public 
  90. * @return string 
  91. */ 
  92. public function get_content_html() { 
  93. return wc_get_template_html( $this->template_html, array( 
  94. 'order' => $this->object,  
  95. 'email_heading' => $this->get_heading(),  
  96. 'sent_to_admin' => false,  
  97. 'plain_text' => false,  
  98. 'email' => $this,  
  99. ) ); 
  100.  
  101. /** 
  102. * Get content plain. 
  103. * @access public 
  104. * @return string 
  105. */ 
  106. public function get_content_plain() { 
  107. return wc_get_template_html( $this->template_plain, array( 
  108. 'order' => $this->object,  
  109. 'email_heading' => $this->get_heading(),  
  110. 'sent_to_admin' => false,  
  111. 'plain_text' => true,  
  112. 'email' => $this,  
  113. ) ); 
  114.  
  115. /** 
  116. * Initialise settings form fields. 
  117. */ 
  118. public function init_form_fields() { 
  119. $this->form_fields = array( 
  120. 'subject' => array( 
  121. 'title' => __( 'Email subject', 'woocommerce' ),  
  122. 'type' => 'text',  
  123. /** translators: %s: default subject */ 
  124. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject . '</code>' ),  
  125. 'placeholder' => '',  
  126. 'default' => '',  
  127. 'desc_tip' => true,  
  128. ),  
  129. 'heading' => array( 
  130. 'title' => __( 'Email heading', 'woocommerce' ),  
  131. 'type' => 'text',  
  132. /** translators: %s: default heading */ 
  133. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading . '</code>' ),  
  134. 'placeholder' => '',  
  135. 'default' => '',  
  136. 'desc_tip' => true,  
  137. ),  
  138. 'subject_paid' => array( 
  139. 'title' => __( 'Email subject (paid)', 'woocommerce' ),  
  140. 'type' => 'text',  
  141. /** translators: %s: default subject */ 
  142. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject_paid . '</code>' ),  
  143. 'placeholder' => '',  
  144. 'default' => '',  
  145. 'desc_tip' => true,  
  146. ),  
  147. 'heading_paid' => array( 
  148. 'title' => __( 'Email heading (paid)', 'woocommerce' ),  
  149. 'type' => 'text',  
  150. /** translators: %s: default heading */ 
  151. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading_paid . '</code>' ),  
  152. 'placeholder' => '',  
  153. 'default' => '',  
  154. 'desc_tip' => true,  
  155. ),  
  156. 'email_type' => array( 
  157. 'title' => __( 'Email type', 'woocommerce' ),  
  158. 'type' => 'select',  
  159. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),  
  160. 'default' => 'html',  
  161. 'class' => 'email_type wc-enhanced-select',  
  162. 'options' => $this->get_email_type_options(),  
  163. 'desc_tip' => true,  
  164. ),  
  165. );