WC_Email_Customer_Refunded_Order

Customer Refunded Order Email.

Defined (1)

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

/includes/emails/class-wc-email-customer-refunded-order.php  
  1. class WC_Email_Customer_Refunded_Order extends WC_Email { 
  2.  
  3. /** 
  4. * Refund order. 
  5. * @var WC_Order|bool 
  6. */ 
  7. public $refund; 
  8.  
  9. /** 
  10. * Is the order partial refunded? 
  11. * @var bool 
  12. */ 
  13. public $partial_refund; 
  14.  
  15. /** 
  16. * Constructor. 
  17. */ 
  18. public function __construct() { 
  19. $this->set_email_strings(); 
  20. $this->customer_email = true; 
  21.  
  22. // Triggers for this email 
  23. add_action( 'woocommerce_order_fully_refunded_notification', array( $this, 'trigger_full' ), 10, 2 ); 
  24. add_action( 'woocommerce_order_partially_refunded_notification', array( $this, 'trigger_partial' ), 10, 2 ); 
  25.  
  26. // Call parent constuctor 
  27. parent::__construct(); 
  28.  
  29. /** 
  30. * Set email strings. 
  31. * @param bool $partial_refund 
  32. */ 
  33. public function set_email_strings( $partial_refund = false ) { 
  34. $this->subject_partial = $this->get_option( 'subject_partial', __( 'Your {site_title} order from {order_date} has been partially refunded', 'woocommerce' ) ); 
  35. $this->subject_full = $this->get_option( 'subject_full', __( 'Your {site_title} order from {order_date} has been refunded', 'woocommerce' ) ); 
  36.  
  37. $this->heading_full = $this->get_option( 'heading_full', __( 'Your order has been fully refunded', 'woocommerce' ) ); 
  38. $this->heading_partial = $this->get_option( 'heading_partial', __( 'Your order has been partially refunded', 'woocommerce' ) ); 
  39.  
  40. $this->template_html = 'emails/customer-refunded-order.php'; 
  41. $this->template_plain = 'emails/plain/customer-refunded-order.php'; 
  42.  
  43. if ( $partial_refund ) { 
  44. $this->id = 'customer_partially_refunded_order'; 
  45. $this->title = __( 'Partially refunded order', 'woocommerce' ); 
  46. $this->description = __( 'Order partially refunded emails are sent to customers when their orders are partially refunded.', 'woocommerce' ); 
  47. $this->heading = $this->heading_partial; 
  48. $this->subject = $this->subject_partial; 
  49. } else { 
  50. $this->id = 'customer_refunded_order'; 
  51. $this->title = __( 'Refunded order', 'woocommerce' ); 
  52. $this->description = __( 'Order refunded emails are sent to customers when their orders are marked refunded.', 'woocommerce' ); 
  53. $this->heading = $this->heading_full; 
  54. $this->subject = $this->subject_full; 
  55.  
  56. /** 
  57. * Full refund notification. 
  58. * @param int $order_id 
  59. * @param int $refund_id 
  60. */ 
  61. public function trigger_full( $order_id, $refund_id = null ) { 
  62. $this->trigger( $order_id, false, $refund_id ); 
  63.  
  64. /** 
  65. * Partial refund notification. 
  66. * @param int $order_id 
  67. * @param int $refund_id 
  68. */ 
  69. public function trigger_partial( $order_id, $refund_id = null ) { 
  70. $this->trigger( $order_id, true, $refund_id ); 
  71.  
  72. /** 
  73. * Trigger. 
  74. * @param int $order_id 
  75. * @param bool $partial_refund 
  76. * @param int $refund_id 
  77. */ 
  78. public function trigger( $order_id, $partial_refund = false, $refund_id = null ) { 
  79. $this->partial_refund = $partial_refund; 
  80. $this->set_email_strings( $partial_refund ); 
  81.  
  82. if ( $order_id ) { 
  83. $this->object = wc_get_order( $order_id ); 
  84. $this->recipient = $this->object->get_billing_email(); 
  85.  
  86. $this->find['order-date'] = '{order_date}'; 
  87. $this->find['order-number'] = '{order_number}'; 
  88.  
  89. $this->replace['order-date'] = wc_format_datetime( $this->object->get_date_created() ); 
  90. $this->replace['order-number'] = $this->object->get_order_number(); 
  91.  
  92. if ( ! empty( $refund_id ) ) { 
  93. $this->refund = wc_get_order( $refund_id ); 
  94. } else { 
  95. $this->refund = false; 
  96.  
  97. if ( ! $this->is_enabled() || ! $this->get_recipient() ) { 
  98. return; 
  99.  
  100. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); 
  101.  
  102. /** 
  103. * Get email subject. 
  104. * @access public 
  105. * @return string 
  106. */ 
  107. public function get_subject() { 
  108. return apply_filters( 'woocommerce_email_subject_customer_refunded_order', $this->format_string( $this->subject ), $this->object ); 
  109.  
  110. /** 
  111. * Get email heading. 
  112. * @access public 
  113. * @return string 
  114. */ 
  115. public function get_heading() { 
  116. return apply_filters( 'woocommerce_email_heading_customer_refunded_order', $this->format_string( $this->heading ), $this->object ); 
  117.  
  118. /** 
  119. * Get content html. 
  120. * @access public 
  121. * @return string 
  122. */ 
  123. public function get_content_html() { 
  124. return wc_get_template_html( $this->template_html, array( 
  125. 'order' => $this->object,  
  126. 'refund' => $this->refund,  
  127. 'partial_refund' => $this->partial_refund,  
  128. 'email_heading' => $this->get_heading(),  
  129. 'sent_to_admin' => false,  
  130. 'plain_text' => false,  
  131. 'email' => $this,  
  132. ) ); 
  133.  
  134. /** 
  135. * Get content plain. 
  136. * @return string 
  137. */ 
  138. public function get_content_plain() { 
  139. return wc_get_template_html( $this->template_plain, array( 
  140. 'order' => $this->object,  
  141. 'refund' => $this->refund,  
  142. 'partial_refund' => $this->partial_refund,  
  143. 'email_heading' => $this->get_heading(),  
  144. 'sent_to_admin' => false,  
  145. 'plain_text' => true,  
  146. 'email' => $this,  
  147. ) ); 
  148.  
  149. /** 
  150. * Initialise settings form fields. 
  151. */ 
  152. public function init_form_fields() { 
  153. $this->form_fields = array( 
  154. 'enabled' => array( 
  155. 'title' => __( 'Enable/Disable', 'woocommerce' ),  
  156. 'type' => 'checkbox',  
  157. 'label' => __( 'Enable this email notification', 'woocommerce' ),  
  158. 'default' => 'yes',  
  159. ),  
  160. 'subject_full' => array( 
  161. 'title' => __( 'Full refund subject', 'woocommerce' ),  
  162. 'type' => 'text',  
  163. /** translators: %s: default subject */ 
  164. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject_full . '</code>' ),  
  165. 'placeholder' => '',  
  166. 'default' => $this->subject_full,  
  167. 'desc_tip' => true,  
  168. ),  
  169. 'subject_partial' => array( 
  170. 'title' => __( 'Partial refund subject', 'woocommerce' ),  
  171. 'type' => 'text',  
  172. /** translators: %s: default subject */ 
  173. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->subject_partial . '</code>' ),  
  174. 'placeholder' => '',  
  175. 'default' => $this->subject_partial,  
  176. 'desc_tip' => true,  
  177. ),  
  178. 'heading_full' => array( 
  179. 'title' => __( 'Full refund email heading', 'woocommerce' ),  
  180. 'type' => 'text',  
  181. /** translators: %s: default heading */ 
  182. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading_full . '</code>' ),  
  183. 'placeholder' => '',  
  184. 'default' => $this->heading_full,  
  185. 'desc_tip' => true,  
  186. ),  
  187. 'heading_partial' => array( 
  188. 'title' => __( 'Partial refund email heading', 'woocommerce' ),  
  189. 'type' => 'text',  
  190. /** translators: %s: default heading */ 
  191. 'description' => sprintf( __( 'Defaults to %s', 'woocommerce' ), '<code>' . $this->heading_partial . '</code>' ),  
  192. 'placeholder' => '',  
  193. 'default' => $this->heading_partial,  
  194. 'desc_tip' => true,  
  195. ),  
  196. 'email_type' => array( 
  197. 'title' => __( 'Email type', 'woocommerce' ),  
  198. 'type' => 'select',  
  199. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),  
  200. 'default' => 'html',  
  201. 'class' => 'email_type wc-enhanced-select',  
  202. 'options' => $this->get_email_type_options(),  
  203. 'desc_tip' => true,  
  204. ),  
  205. );