WC_Email_Customer_Completed_Order

Customer Completed Order Email.

Defined (1)

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

/includes/emails/class-wc-email-customer-completed-order.php  
  1. class WC_Email_Customer_Completed_Order extends WC_Email { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7.  
  8. $this->id = 'customer_completed_order'; 
  9. $this->customer_email = true; 
  10. $this->title = __( 'Completed order', 'woocommerce' ); 
  11. $this->description = __( 'Order complete emails are sent to customers when their orders are marked completed and usually indicate that their orders have been shipped.', 'woocommerce' ); 
  12.  
  13. $this->heading = __( 'Your order is complete', 'woocommerce' ); 
  14. $this->subject = __( 'Your {site_title} order from {order_date} is complete', 'woocommerce' ); 
  15.  
  16. $this->template_html = 'emails/customer-completed-order.php'; 
  17. $this->template_plain = 'emails/plain/customer-completed-order.php'; 
  18.  
  19. // Triggers for this email 
  20. add_action( 'woocommerce_order_status_completed_notification', array( $this, 'trigger' ), 10, 2 ); 
  21.  
  22. // Other settings 
  23. $this->heading_downloadable = $this->get_option( 'heading_downloadable', __( 'Your order is complete - download your files', 'woocommerce' ) ); 
  24. $this->subject_downloadable = $this->get_option( 'subject_downloadable', __( 'Your {site_title} order from {order_date} is complete - download your files', 'woocommerce' ) ); 
  25.  
  26. // Call parent constuctor 
  27. parent::__construct(); 
  28.  
  29. /** 
  30. * Trigger the sending of this email. 
  31. * @param int $order_id The order ID. 
  32. * @param WC_Order $order Order object. 
  33. */ 
  34. public function trigger( $order_id, $order = false ) { 
  35. if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { 
  36. $order = wc_get_order( $order_id ); 
  37.  
  38. if ( is_a( $order, 'WC_Order' ) ) { 
  39. $this->object = $order; 
  40. $this->recipient = $this->object->get_billing_email(); 
  41.  
  42. $this->find['order-date'] = '{order_date}'; 
  43. $this->find['order-number'] = '{order_number}'; 
  44.  
  45. $this->replace['order-date'] = wc_format_datetime( $this->object->get_date_created() ); 
  46. $this->replace['order-number'] = $this->object->get_order_number(); 
  47.  
  48. if ( ! $this->is_enabled() || ! $this->get_recipient() ) { 
  49. return; 
  50.  
  51. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); 
  52.  
  53. /** 
  54. * Get email subject. 
  55. * @access public 
  56. * @return string 
  57. */ 
  58. public function get_subject() { 
  59. if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) { 
  60. return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject_downloadable ), $this->object ); 
  61. } else { 
  62. return apply_filters( 'woocommerce_email_subject_customer_completed_order', $this->format_string( $this->subject ), $this->object ); 
  63.  
  64. /** 
  65. * Get email heading. 
  66. * @access public 
  67. * @return string 
  68. */ 
  69. public function get_heading() { 
  70. if ( ! empty( $this->object ) && $this->object->has_downloadable_item() ) { 
  71. return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading_downloadable ), $this->object ); 
  72. } else { 
  73. return apply_filters( 'woocommerce_email_heading_customer_completed_order', $this->format_string( $this->heading ), $this->object ); 
  74.  
  75. /** 
  76. * Get content html. 
  77. * @access public 
  78. * @return string 
  79. */ 
  80. public function get_content_html() { 
  81. return wc_get_template_html( $this->template_html, array( 
  82. 'order' => $this->object,  
  83. 'email_heading' => $this->get_heading(),  
  84. 'sent_to_admin' => false,  
  85. 'plain_text' => false,  
  86. 'email' => $this,  
  87. ) ); 
  88.  
  89. /** 
  90. * Get content plain. 
  91. * @return string 
  92. */ 
  93. public function get_content_plain() { 
  94. return wc_get_template_html( $this->template_plain, array( 
  95. 'order' => $this->object,  
  96. 'email_heading' => $this->get_heading(),  
  97. 'sent_to_admin' => false,  
  98. 'plain_text' => true,  
  99. 'email' => $this,  
  100. ) ); 
  101.  
  102. /** 
  103. * Initialise settings form fields. 
  104. */ 
  105. public function init_form_fields() { 
  106. $this->form_fields = array( 
  107. 'enabled' => array( 
  108. 'title' => __( 'Enable/Disable', 'woocommerce' ),  
  109. 'type' => 'checkbox',  
  110. 'label' => __( 'Enable this email notification', 'woocommerce' ),  
  111. 'default' => 'yes',  
  112. ),  
  113. 'subject' => array( 
  114. 'title' => __( 'Subject', 'woocommerce' ),  
  115. 'type' => 'text',  
  116. /** translators: %s: default subject */ 
  117. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject . '</code>' ),  
  118. 'placeholder' => '',  
  119. 'default' => '',  
  120. 'desc_tip' => true,  
  121. ),  
  122. 'heading' => array( 
  123. 'title' => __( 'Email heading', 'woocommerce' ),  
  124. 'type' => 'text',  
  125. /** translators: %s: default heading */ 
  126. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading . '</code>' ),  
  127. 'placeholder' => '',  
  128. 'default' => '',  
  129. 'desc_tip' => true,  
  130. ),  
  131. 'subject_downloadable' => array( 
  132. 'title' => __( 'Subject (downloadable)', 'woocommerce' ),  
  133. 'type' => 'text',  
  134. /** translators: %s: default subject */ 
  135. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject_downloadable . '</code>' ),  
  136. 'placeholder' => '',  
  137. 'default' => '',  
  138. 'desc_tip' => true,  
  139. ),  
  140. 'heading_downloadable' => array( 
  141. 'title' => __( 'Email heading (downloadable)', 'woocommerce' ),  
  142. 'type' => 'text',  
  143. /** translators: %s: default heading */ 
  144. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading_downloadable . '</code>' ),  
  145. 'placeholder' => '',  
  146. 'default' => '',  
  147. 'desc_tip' => true,  
  148. ),  
  149. 'email_type' => array( 
  150. 'title' => __( 'Email type', 'woocommerce' ),  
  151. 'type' => 'select',  
  152. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),  
  153. 'default' => 'html',  
  154. 'class' => 'email_type wc-enhanced-select',  
  155. 'options' => $this->get_email_type_options(),  
  156. 'desc_tip' => true,  
  157. ),  
  158. );