WC_Email_Failed_Order

Failed Order Email.

Defined (1)

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

/includes/emails/class-wc-email-failed-order.php  
  1. class WC_Email_Failed_Order extends WC_Email { 
  2.  
  3. /** 
  4. * Constructor. 
  5. */ 
  6. public function __construct() { 
  7. $this->id = 'failed_order'; 
  8. $this->title = __( 'Failed order', 'woocommerce' ); 
  9. $this->description = __( 'Failed order emails are sent to chosen recipient(s) when orders have been marked failed (if they were previously processing or on-hold).', 'woocommerce' ); 
  10. $this->heading = __( 'Failed order', 'woocommerce' ); 
  11. $this->subject = __( '[{site_title}] Failed order ({order_number})', 'woocommerce' ); 
  12. $this->template_html = 'emails/admin-failed-order.php'; 
  13. $this->template_plain = 'emails/plain/admin-failed-order.php'; 
  14.  
  15. // Triggers for this email 
  16. add_action( 'woocommerce_order_status_pending_to_failed_notification', array( $this, 'trigger' ), 10, 2 ); 
  17. add_action( 'woocommerce_order_status_on-hold_to_failed_notification', array( $this, 'trigger' ), 10, 2 ); 
  18.  
  19. // Call parent constructor 
  20. parent::__construct(); 
  21.  
  22. // Other settings 
  23. $this->recipient = $this->get_option( 'recipient', get_option( 'admin_email' ) ); 
  24.  
  25. /** 
  26. * Trigger the sending of this email. 
  27. * @param int $order_id The order ID. 
  28. * @param WC_Order $order Order object. 
  29. */ 
  30. public function trigger( $order_id, $order = false ) { 
  31. if ( $order_id && ! is_a( $order, 'WC_Order' ) ) { 
  32. $order = wc_get_order( $order_id ); 
  33.  
  34. if ( is_a( $order, 'WC_Order' ) ) { 
  35. $this->object = $order; 
  36. $this->find['order-date'] = '{order_date}'; 
  37. $this->find['order-number'] = '{order_number}'; 
  38. $this->replace['order-date'] = wc_format_datetime( $this->object->get_date_created() ); 
  39. $this->replace['order-number'] = $this->object->get_order_number(); 
  40.  
  41. if ( ! $this->is_enabled() || ! $this->get_recipient() ) { 
  42. return; 
  43.  
  44. $this->send( $this->get_recipient(), $this->get_subject(), $this->get_content(), $this->get_headers(), $this->get_attachments() ); 
  45.  
  46. /** 
  47. * Get content html. 
  48. * @access public 
  49. * @return string 
  50. */ 
  51. public function get_content_html() { 
  52. return wc_get_template_html( $this->template_html, array( 
  53. 'order' => $this->object,  
  54. 'email_heading' => $this->get_heading(),  
  55. 'sent_to_admin' => true,  
  56. 'plain_text' => false,  
  57. 'email' => $this,  
  58. ) ); 
  59.  
  60. /** 
  61. * Get content plain. 
  62. * @return string 
  63. */ 
  64. public function get_content_plain() { 
  65. return wc_get_template_html( $this->template_plain, array( 
  66. 'order' => $this->object,  
  67. 'email_heading' => $this->get_heading(),  
  68. 'sent_to_admin' => true,  
  69. 'plain_text' => true,  
  70. 'email' => $this,  
  71. ) ); 
  72.  
  73. /** 
  74. * Initialise settings form fields. 
  75. */ 
  76. public function init_form_fields() { 
  77. $this->form_fields = array( 
  78. 'enabled' => array( 
  79. 'title' => __( 'Enable/Disable', 'woocommerce' ),  
  80. 'type' => 'checkbox',  
  81. 'label' => __( 'Enable this email notification', 'woocommerce' ),  
  82. 'default' => 'yes',  
  83. ),  
  84. 'recipient' => array( 
  85. 'title' => __( 'Recipient(s)', 'woocommerce' ),  
  86. 'type' => 'text',  
  87. 'description' => sprintf( __( 'Enter recipients (comma separated) for this email. Defaults to %s.', 'woocommerce' ), '<code>' . esc_attr( get_option( 'admin_email' ) ) . '</code>' ),  
  88. 'placeholder' => '',  
  89. 'default' => '',  
  90. 'desc_tip' => true,  
  91. ),  
  92. 'subject' => array( 
  93. 'title' => __( 'Subject', 'woocommerce' ),  
  94. 'type' => 'text',  
  95. 'description' => sprintf( __( 'This controls the email subject line. Leave blank to use the default subject: %s.', 'woocommerce' ), '<code>' . $this->subject . '</code>' ),  
  96. 'placeholder' => '',  
  97. 'default' => '',  
  98. 'desc_tip' => true,  
  99. ),  
  100. 'heading' => array( 
  101. 'title' => __( 'Email heading', 'woocommerce' ),  
  102. 'type' => 'text',  
  103. 'description' => sprintf( __( 'This controls the main heading contained within the email notification. Leave blank to use the default heading: %s.', 'woocommerce' ), '<code>' . $this->heading . '</code>' ),  
  104. 'placeholder' => '',  
  105. 'default' => '',  
  106. 'desc_tip' => true,  
  107. ),  
  108. 'email_type' => array( 
  109. 'title' => __( 'Email type', 'woocommerce' ),  
  110. 'type' => 'select',  
  111. 'description' => __( 'Choose which format of email to send.', 'woocommerce' ),  
  112. 'default' => 'html',  
  113. 'class' => 'email_type wc-enhanced-select',  
  114. 'options' => $this->get_email_type_options(),  
  115. 'desc_tip' => true,  
  116. ),  
  117. );